Skip to content

Commit 314aba9

Browse files
committedMay 26, 2021
fix: namespace should default to html
not previous namespace
1 parent f4e594a commit 314aba9

10 files changed

+28
-9
lines changed
 

‎dist/purify.cjs.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎dist/purify.cjs.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎dist/purify.es.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎dist/purify.es.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎dist/purify.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎dist/purify.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎dist/purify.min.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎dist/purify.min.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎src/purify.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,7 @@ function createDOMPurify(window = getGlobal()) {
384384
KEEP_CONTENT = cfg.KEEP_CONTENT !== false; // Default true
385385
IN_PLACE = cfg.IN_PLACE || false; // Default false
386386
IS_ALLOWED_URI = cfg.ALLOWED_URI_REGEXP || IS_ALLOWED_URI;
387-
NAMESPACE = cfg.NAMESPACE || NAMESPACE;
387+
NAMESPACE = cfg.NAMESPACE || HTML_NAMESPACE;
388388
if (SAFE_FOR_TEMPLATES) {
389389
ALLOW_DATA_ATTR = false;
390390
}

‎test/test-suite.js

+19
Original file line numberDiff line numberDiff line change
@@ -1615,4 +1615,23 @@ module.exports = function (DOMPurify, window, tests, xssTests) {
16151615
assert.contains(clean, test.expected);
16161616
});
16171617
});
1618+
1619+
QUnit.test('Test namespace default to html after other namespace been used', function (assert) {
1620+
var tests = [
1621+
{
1622+
test: '<br>',
1623+
config: { NAMESPACE: 'http://www.w3.org/2000/svg' },
1624+
expected: [''],
1625+
},
1626+
{
1627+
test: '<br>',
1628+
config: { },
1629+
expected: ['<br>'],
1630+
},
1631+
];
1632+
tests.forEach(function (test) {
1633+
var clean = DOMPurify.sanitize(test.test, test.config);
1634+
assert.contains(clean, test.expected);
1635+
});
1636+
});
16181637
};

0 commit comments

Comments
 (0)
Please sign in to comment.