mirror of
https://github.com/hanzoai/DOMPurify.git
synced 2026-09-24 16:55:05 +00:00
fix: Added fixes for the jsdom parser issue in 2.x
This commit is contained in:
Vendored
+1
-1
@@ -1190,7 +1190,7 @@ function createDOMPurify() {
|
||||
}
|
||||
|
||||
/* Work around a security issue with comments inside attributes */
|
||||
if (SAFE_FOR_XML && regExpTest(/((--!?|])>)|<\/(style|title)/i, value)) {
|
||||
if (SAFE_FOR_XML && regExpTest(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i, value)) {
|
||||
_removeAttribute(name, currentNode);
|
||||
continue;
|
||||
}
|
||||
|
||||
Vendored
+1
-1
File diff suppressed because one or more lines are too long
Vendored
+1
-1
@@ -1188,7 +1188,7 @@ function createDOMPurify() {
|
||||
}
|
||||
|
||||
/* Work around a security issue with comments inside attributes */
|
||||
if (SAFE_FOR_XML && regExpTest(/((--!?|])>)|<\/(style|title)/i, value)) {
|
||||
if (SAFE_FOR_XML && regExpTest(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i, value)) {
|
||||
_removeAttribute(name, currentNode);
|
||||
continue;
|
||||
}
|
||||
|
||||
Vendored
+1
-1
File diff suppressed because one or more lines are too long
Vendored
+1
-1
@@ -1194,7 +1194,7 @@
|
||||
}
|
||||
|
||||
/* Work around a security issue with comments inside attributes */
|
||||
if (SAFE_FOR_XML && regExpTest(/((--!?|])>)|<\/(style|title)/i, value)) {
|
||||
if (SAFE_FOR_XML && regExpTest(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i, value)) {
|
||||
_removeAttribute(name, currentNode);
|
||||
continue;
|
||||
}
|
||||
|
||||
Vendored
+1
-1
File diff suppressed because one or more lines are too long
Vendored
+1
-1
File diff suppressed because one or more lines are too long
Vendored
+1
-1
File diff suppressed because one or more lines are too long
+7
-1
@@ -1301,7 +1301,13 @@ function createDOMPurify(window = getGlobal()) {
|
||||
}
|
||||
|
||||
/* Work around a security issue with comments inside attributes */
|
||||
if (SAFE_FOR_XML && regExpTest(/((--!?|])>)|<\/(style|title)/i, value)) {
|
||||
if (
|
||||
SAFE_FOR_XML &&
|
||||
regExpTest(
|
||||
/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,
|
||||
value
|
||||
)
|
||||
) {
|
||||
_removeAttribute(name, currentNode);
|
||||
continue;
|
||||
}
|
||||
|
||||
Vendored
+9
-8
@@ -747,7 +747,8 @@ module.exports = [
|
||||
"<div id=\"102\"><img src=\"x` `<script>alert(102)</script>\">//[\"'`-->]]>]</div>",
|
||||
"<div id=\"102\"><img src=\"x` `<script>alert(102)</script>\">//[\"'`-->]]>]</div>",
|
||||
"<div id=\"102\"><img src=\"x%60%20%60%3Cscript%3Ealert%28102%29%3C/script%3E\">//[\"'`-->]]>]</div>",
|
||||
"<div id=\"102\">//[\"'`-->]]>]</div>"
|
||||
"<div id=\"102\">//[\"'`-->]]>]</div>",
|
||||
"<div id=\"102\"><img>//[\"'`-->]]>]</div>"
|
||||
]
|
||||
}, {
|
||||
"payload": "<div id=\"103\"><script>history.pushState(0,0,'/i/am/somewhere_else');</script>//[\"'`-->]]>]</div><div id=\"104\"><svg xmlns=\"http://www.w3.org/2000/svg\" id=\"foo\">\n<x xmlns=\"http://www.w3.org/2001/xml-events\" event=\"load\" observer=\"foo\" handler=\"data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%3E%0A%3Chandler%20xml%3Aid%3D%22bar%22%20type%3D%22application%2Fecmascript%22%3E alert(104) %3C%2Fhandler%3E%0A%3C%2Fsvg%3E%0A#bar\"/>\n</svg>//[\"'`-->]]>]</div>",
|
||||
@@ -940,13 +941,13 @@ module.exports = [
|
||||
"title": "XMP",
|
||||
"payload": "<div id=\"134\"><xmp>\n<%\n</xmp>\n<img alt='%></xmp><img src=xx onerror=alert(134)//'>\n\n<script>\nx='<%'\n</script> %>/\nalert(2)\n</script>\n\nXXX\n<style>\n*['<!--']{}\n</style>\n-->{}\n*{color:red}</style>//[\"'`-->]]>]</div>",
|
||||
"expected": [
|
||||
"<div id=\"134\">\n<%\n\n<img alt=\"%></xmp><img src=xx onerror=alert(134)//\">\n\n %>/\nalert(2)\n\n\nXXX\n<style>\n*['<!--']{}\n</style>\n-->{}\n*{color:red}//[\"'`-->]]>]</div>",
|
||||
"<div id=\"134\">\n<%\n\n<img alt=\"%></xmp><img src=xx onerror=alert(134)//\">\n\n %>/\nalert(2)\n\n\nXXX\n<style>\n*['<!--']{}\n</style>\n-->{}\n*{color:red}//[\"'`-->]]>]</div>",
|
||||
"<div id=\"134\">\n<%\n\n\n\n %>/\nalert(2)\n\n\nXXX\n<style>\n*['<!--']{}\n</style>\n-->{}\n*{color:red}//[\"'`-->]]>]</div>",
|
||||
"<div id=\"134\">\n<img alt=\"%></xmp><img src=xx onerror=alert(134)//\">\n\n %>/\nalert(2)\n\n\nXXX\n<style>\n*['<!--']{}\n</style>\n-->{}\n*{color:red}//[\"'`-->]]>]</div>",
|
||||
"<div id=\"134\">\n<img alt=\"%></xmp><img src=xx onerror=alert(134)//\">\n\n %>/\nalert(2)\n\n\nXXX\n<style>\n*['<!--']{}\n</style>\n->{}\n*{color:red}//[\"'`-->]]>]</div>",
|
||||
"<div id=\"134\">\n<img alt=\"%></xmp><img src=xx onerror=alert(134)//\">\n\n %>/\nalert(2)\n\n\nXXX\n\n-->{}\n*{color:red}//[\"'`-->]]>]</div>"
|
||||
]
|
||||
"<div id=\"134\">\n<img alt=\"%></xmp><img src=xx onerror=alert(134)//\">\n\n %>/\nalert(2)\n\n\nXXX\n<style>\n*['<!--']{}\n</style>\n-->{}\n*{color:red}//[\"'`-->]]>]</div>",
|
||||
"<div id=\"134\">\n<img alt=\"%></xmp><img src=xx onerror=alert(134)//\">\n\n %>/\nalert(2)\n\n\nXXX\n<style>\n*['<!--']{}\n</style>\n->{}\n*{color:red}//[\"'`-->]]>]</div>",
|
||||
"<div id=\"134\">\n<img alt=\"%></xmp><img src=xx onerror=alert(134)//\">\n\n %>/\nalert(2)\n\n\nXXX\n\n-->{}\n*{color:red}//[\"'`-->]]>]</div>",
|
||||
"<div id=\"134\">\n<img alt=\"%></xmp><img src=xx onerror=alert(134)//\">\n\n %>/\nalert(2)\n\n\nXXX\n\n-->{}\n*{color:red}//[\"'`-->]]>]</div>",
|
||||
"<div id=\"134\">\n<img>\n\n %>/\nalert(2)\n\n\nXXX\n\n-->{}\n*{color:red}//[\"'`-->]]>]</div>",
|
||||
"<div id=\"134\">\n<img>\n\n %>/\nalert(2)\n\n\nXXX\n<style>\n*['<!--']{}\n</style>\n-->{}\n*{color:red}//[\"'`-->]]>]</div>"
|
||||
]
|
||||
}, {
|
||||
"title": "SVG",
|
||||
"payload": "<div id=\"135\"><?xml-stylesheet type=\"text/xsl\" href=\"#\" ?>\n<stylesheet xmlns=\"http://www.w3.org/TR/WD-xsl\">\n<template match=\"/\">\n<eval>new ActiveXObject('htmlfile').parentWindow.alert(135)</eval>\n<if expr=\"new ActiveXObject('htmlfile').parentWindow.alert(2)\"></if>\n</template>\n</stylesheet>//[\"'`-->]]>]</div>",
|
||||
|
||||
+7
-5
@@ -135,17 +135,18 @@
|
||||
);
|
||||
QUnit.test('Config-Flag tests: ALLOW_SELF_CLOSE_IN_ATTR', function (assert) {
|
||||
// ALLOW_SELF_CLOSE_IN_ATTR
|
||||
assert.equal(
|
||||
assert.contains(
|
||||
DOMPurify.sanitize('<a href="#" class="foo <br/>">abc</a>', {
|
||||
ALLOW_SELF_CLOSE_IN_ATTR: false,
|
||||
}),
|
||||
'<a href="#">abc</a>'
|
||||
['<a href="#">abc</a>', "<a class=\"foo <br/>\" href=\"#\">abc</a>"]
|
||||
|
||||
);
|
||||
assert.equal(
|
||||
assert.contains(
|
||||
DOMPurify.sanitize('<a href="#" class="foo <br/>">abc</a>', {
|
||||
ALLOW_SELF_CLOSE_IN_ATTR: true,
|
||||
}),
|
||||
'<a class="foo <br/>" href="#">abc</a>'
|
||||
['<a class="foo <br/>" href="#">abc</a>', "<a class=\"foo <br/>\" href=\"#\">abc</a>"]
|
||||
);
|
||||
});
|
||||
QUnit.test('Config-Flag tests: ALLOW_DATA_ATTR', function (assert) {
|
||||
@@ -1644,7 +1645,8 @@
|
||||
'<img y="<x">',
|
||||
'<img y="<x">',
|
||||
'<img y="<x">',
|
||||
"<img x=\"/><img src=x onerror=alert(1)>\" y=\"<x\">"
|
||||
"<img x=\"/><img src=x onerror=alert(1)>\" y=\"<x\">",
|
||||
"<img y=\"<x\" x=\"/><img src=x onerror=alert(1)>\">"
|
||||
]);
|
||||
}
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user