Update handling of quoteStart to prevent sanitization bypass using non-space whitespace.
This commit is contained in:
@@ -89,7 +89,7 @@ function parseTag(html, onTag, escapeHtml) {
|
||||
var i = 1;
|
||||
var ic = html.charAt(currentPos - i);
|
||||
|
||||
while ((ic === " ") || (ic === "=")) {
|
||||
while ((ic.trim() === "") || (ic === "=")) {
|
||||
if (ic === "=") {
|
||||
quoteStart = c;
|
||||
continue chariterator;
|
||||
|
||||
@@ -360,7 +360,7 @@ describe("test custom XSS method", function() {
|
||||
);
|
||||
});
|
||||
|
||||
it("#onTag - sanitize html parameter", function() {
|
||||
it("#onTag - sanitize html parameter space", function() {
|
||||
var source = '<a target= " href="><script>alert(2)</script>"><span>';
|
||||
var i = 0;
|
||||
var html = xss(source, {
|
||||
@@ -374,4 +374,19 @@ describe("test custom XSS method", function() {
|
||||
debug(html);
|
||||
assert.equal(html, '<a target= " href="><span><script>alert(2)</script>"><span>');
|
||||
});
|
||||
|
||||
it("#onTag - sanitize html parameter tab", function() {
|
||||
var source = '<a target= " href="><script>alert(2)</script>"><span>';
|
||||
var i = 0;
|
||||
var html = xss(source, {
|
||||
onTag: function(_, E, S) {
|
||||
if (S.isWhite && "a" === _) {
|
||||
if (S.isClosing) return "</span></a>";
|
||||
return "".concat(E, '<span>');
|
||||
}
|
||||
}
|
||||
});
|
||||
debug(html);
|
||||
assert.equal(html, '<a target= " href="><span><script>alert(2)</script>"><span>');
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user