Skip to content

Commit 0228425

Browse files
committedSep 23, 2020
test: stripped SAFE_FOR_JQUERY from several tests
1 parent 4eb5d93 commit 0228425

File tree

1 file changed

+21
-53
lines changed

1 file changed

+21
-53
lines changed
 

‎test/test-suite.js

+21-53
Original file line numberDiff line numberDiff line change
@@ -149,77 +149,50 @@ module.exports = function (DOMPurify, window, tests, xssTests) {
149149
'<my-component my-attr="foo">abc</my-component>'
150150
);
151151
});
152-
QUnit.test('Config-Flag tests: SAFE_FOR_JQUERY', function (assert) {
153-
//SAFE_FOR_JQUERY
152+
QUnit.test('Config-Flag tests: SAFE_FOR_JQUERY (now inactive, secure by default)', function (assert) {
154153
assert.equal(
155-
DOMPurify.sanitize(
156-
'<a>123</a><option><style><img src=x onerror=alert(1)>',
157-
{ SAFE_FOR_JQUERY: false }
158-
),
154+
DOMPurify.sanitize('<a>123</a><option><style><img src=x onerror=alert(1)>'),
159155
"<a>123</a><option></option>"
160156
);
161157
assert.equal(
162-
DOMPurify.sanitize(
163-
'<a>123</a><option><style><img src=x onerror=alert(1)>',
164-
{ SAFE_FOR_JQUERY: true }
165-
),
158+
DOMPurify.sanitize('<a>123</a><option><style><img src=x onerror=alert(1)>'),
166159
"<a>123</a><option></option>"
167160
);
168161
assert.equal(
169162
DOMPurify.sanitize(
170-
'<option><style></option></select><b><img src=xx: onerror=alert(1)></style></option>',
171-
{ SAFE_FOR_JQUERY: false }
163+
'<option><style></option></select><b><img src=xx: onerror=alert(1)></style></option>'
172164
),
173165
"<option></option>"
174166
);
175167
assert.equal(
176168
DOMPurify.sanitize(
177-
'<option><style></option></select><b><img src=xx: onerror=alert(1)></style></option>',
178-
{ SAFE_FOR_JQUERY: true }
179-
),
180-
"<option></option>"
181-
);
182-
assert.equal(
183-
DOMPurify.sanitize(
184-
'<option><iframe></select><b><script>alert(1)</script>',
185-
{ SAFE_FOR_JQUERY: false, KEEP_CONTENT: false }
186-
),
169+
'<option><iframe></select><b><script>alert(1)</script>'),
187170
'<option></option>'
188171
);
189172
assert.equal(
190173
DOMPurify.sanitize(
191-
'<option><iframe></select><b><script>alert(1)</script>',
192-
{ SAFE_FOR_JQUERY: true, KEEP_CONTENT: false }
193-
),
174+
'<option><iframe></select><b><script>alert(1)</script>'),
194175
'<option></option>'
195176
);
196177
assert.equal(
197-
DOMPurify.sanitize('<b><style><style/><img src=xx: onerror=alert(1)>', {
198-
SAFE_FOR_JQUERY: false,
199-
}),
178+
DOMPurify.sanitize('<b><style><style/><img src=xx: onerror=alert(1)>'),
200179
'<b></b>'
201180
);
202181
assert.equal(
203-
DOMPurify.sanitize('<b><style><style/><img src=xx: onerror=alert(1)>', {
204-
SAFE_FOR_JQUERY: true,
205-
}),
182+
DOMPurify.sanitize('<b><style><style/><img src=xx: onerror=alert(1)>'),
206183
'<b></b>'
207184
);
208185
assert.contains(
209-
DOMPurify.sanitize('1<template><s>000</s></template>2', {
210-
SAFE_FOR_JQUERY: true,
211-
}),
186+
DOMPurify.sanitize('1<template><s>000</s></template>2'),
212187
['1<template><s>000</s></template>2', '1<template></template>2', '12']
213188
);
214189
assert.contains(
215-
DOMPurify.sanitize('<template><s>000</s></template>', {
216-
SAFE_FOR_JQUERY: true,
217-
}),
190+
DOMPurify.sanitize('<template><s>000</s></template>'),
218191
['', '<template><s>000</s></template>']
219192
);
220193
// see https://github.com/cure53/DOMPurify/issues/283
221194
assert.equal(
222-
DOMPurify.sanitize('<i>&amp;amp; &lt;</i>', { SAFE_FOR_JQUERY: true }),
195+
DOMPurify.sanitize('<i>&amp;amp; &lt;</i>'),
223196
'<i>&amp;amp; &lt;</i>'
224197
);
225198
});
@@ -590,7 +563,7 @@ module.exports = function (DOMPurify, window, tests, xssTests) {
590563
assert
591564
) {
592565
jQuery('#qunit-fixture').html(
593-
DOMPurify.sanitize(params.payload, { SAFE_FOR_JQUERY: true })
566+
DOMPurify.sanitize(params.payload)
594567
);
595568
setTimeout(function () {
596569
QUnit.start();
@@ -880,12 +853,12 @@ module.exports = function (DOMPurify, window, tests, xssTests) {
880853
}
881854
);
882855

883-
// Test 7 to check that DOMPurify.removed is correct in SAFE_FOR_JQUERY mode
856+
// Test 7 to check that DOMPurify.removed is correct
884857
QUnit.test(
885-
'DOMPurify.removed should be correct in SAFE_FOR_JQUERY mode',
858+
'DOMPurify.removed should be correct',
886859
function (assert) {
887860
var dirty = '<option><iframe></select><b><script>alert(1)</script>';
888-
DOMPurify.sanitize(dirty, { SAFE_FOR_JQUERY: true });
861+
DOMPurify.sanitize(dirty);
889862
assert.equal(DOMPurify.removed.length, 1);
890863
}
891864
);
@@ -923,14 +896,13 @@ module.exports = function (DOMPurify, window, tests, xssTests) {
923896
}
924897
);
925898

926-
// Test 11 to check that DOMPurify.removed does not have false positive elements in SAFE_FOR_JQUERY mode
899+
// Test 11 to check that DOMPurify.removed does not have false positive elements
927900
QUnit.test(
928-
'DOMPurify.removed should not contain elements for valid data in SAFE_FOR_JQUERY mode',
901+
'DOMPurify.removed should not contain elements for valid data',
929902
function (assert) {
930903
var dirty = '1';
931904
DOMPurify.sanitize(dirty, {
932-
WHOLE_DOCUMENT: true,
933-
SAFE_FOR_JQUERY: true,
905+
WHOLE_DOCUMENT: true
934906
});
935907
assert.equal(DOMPurify.removed.length, 0);
936908
}
@@ -1402,9 +1374,7 @@ module.exports = function (DOMPurify, window, tests, xssTests) {
14021374
QUnit.test(
14031375
'Test against insecure behavior in jQUery v3.0 and newer 1/2',
14041376
function (assert) {
1405-
var config = {
1406-
SAFE_FOR_JQUERY: true,
1407-
};
1377+
var config = {};
14081378
var clean = DOMPurify.sanitize(
14091379
'<img x="/><img src=x onerror=alert(1)>" y="<x">',
14101380
config
@@ -1420,17 +1390,15 @@ module.exports = function (DOMPurify, window, tests, xssTests) {
14201390
QUnit.test(
14211391
'Test against insecure behavior in jQUery v3.0 and newer 2/2',
14221392
function (assert) {
1423-
var config = {
1424-
SAFE_FOR_JQUERY: true,
1425-
ADD_TAGS: ['noscript'],
1426-
};
1393+
var config = {};
14271394
var clean = DOMPurify.sanitize(
14281395
"a<noscript><p id='><noscript /><img src=x onerror=alert(1)>'></noscript>",
14291396
config
14301397
);
14311398
assert.contains(clean, [
14321399
"a<noscript>&lt;p id='>&lt;noscript />&lt;img src=x onerror=alert(1)>'></noscript>", // jsdom
14331400
'a<noscript><p></p></noscript>',
1401+
"a<p></p>",
14341402
"a"
14351403
]);
14361404
}

0 commit comments

Comments
 (0)
Please sign in to comment.