@@ -149,77 +149,50 @@ module.exports = function (DOMPurify, window, tests, xssTests) {
149
149
'<my-component my-attr="foo">abc</my-component>'
150
150
) ;
151
151
} ) ;
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 ) {
154
153
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)>' ) ,
159
155
"<a>123</a><option></option>"
160
156
) ;
161
157
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)>' ) ,
166
159
"<a>123</a><option></option>"
167
160
) ;
168
161
assert . equal (
169
162
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>'
172
164
) ,
173
165
"<option></option>"
174
166
) ;
175
167
assert . equal (
176
168
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>' ) ,
187
170
'<option></option>'
188
171
) ;
189
172
assert . equal (
190
173
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>' ) ,
194
175
'<option></option>'
195
176
) ;
196
177
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)>' ) ,
200
179
'<b></b>'
201
180
) ;
202
181
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)>' ) ,
206
183
'<b></b>'
207
184
) ;
208
185
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' ) ,
212
187
[ '1<template><s>000</s></template>2' , '1<template></template>2' , '12' ]
213
188
) ;
214
189
assert . contains (
215
- DOMPurify . sanitize ( '<template><s>000</s></template>' , {
216
- SAFE_FOR_JQUERY : true ,
217
- } ) ,
190
+ DOMPurify . sanitize ( '<template><s>000</s></template>' ) ,
218
191
[ '' , '<template><s>000</s></template>' ]
219
192
) ;
220
193
// see https://github.com/cure53/DOMPurify/issues/283
221
194
assert . equal (
222
- DOMPurify . sanitize ( '<i>&amp; <</i>' , { SAFE_FOR_JQUERY : true } ) ,
195
+ DOMPurify . sanitize ( '<i>&amp; <</i>' ) ,
223
196
'<i>&amp; <</i>'
224
197
) ;
225
198
} ) ;
@@ -590,7 +563,7 @@ module.exports = function (DOMPurify, window, tests, xssTests) {
590
563
assert
591
564
) {
592
565
jQuery ( '#qunit-fixture' ) . html (
593
- DOMPurify . sanitize ( params . payload , { SAFE_FOR_JQUERY : true } )
566
+ DOMPurify . sanitize ( params . payload )
594
567
) ;
595
568
setTimeout ( function ( ) {
596
569
QUnit . start ( ) ;
@@ -880,12 +853,12 @@ module.exports = function (DOMPurify, window, tests, xssTests) {
880
853
}
881
854
) ;
882
855
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
884
857
QUnit . test (
885
- 'DOMPurify.removed should be correct in SAFE_FOR_JQUERY mode ' ,
858
+ 'DOMPurify.removed should be correct' ,
886
859
function ( assert ) {
887
860
var dirty = '<option><iframe></select><b><script>alert(1)</script>' ;
888
- DOMPurify . sanitize ( dirty , { SAFE_FOR_JQUERY : true } ) ;
861
+ DOMPurify . sanitize ( dirty ) ;
889
862
assert . equal ( DOMPurify . removed . length , 1 ) ;
890
863
}
891
864
) ;
@@ -923,14 +896,13 @@ module.exports = function (DOMPurify, window, tests, xssTests) {
923
896
}
924
897
) ;
925
898
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
927
900
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' ,
929
902
function ( assert ) {
930
903
var dirty = '1' ;
931
904
DOMPurify . sanitize ( dirty , {
932
- WHOLE_DOCUMENT : true ,
933
- SAFE_FOR_JQUERY : true ,
905
+ WHOLE_DOCUMENT : true
934
906
} ) ;
935
907
assert . equal ( DOMPurify . removed . length , 0 ) ;
936
908
}
@@ -1402,9 +1374,7 @@ module.exports = function (DOMPurify, window, tests, xssTests) {
1402
1374
QUnit . test (
1403
1375
'Test against insecure behavior in jQUery v3.0 and newer 1/2' ,
1404
1376
function ( assert ) {
1405
- var config = {
1406
- SAFE_FOR_JQUERY : true ,
1407
- } ;
1377
+ var config = { } ;
1408
1378
var clean = DOMPurify . sanitize (
1409
1379
'<img x="/><img src=x onerror=alert(1)>" y="<x">' ,
1410
1380
config
@@ -1420,17 +1390,15 @@ module.exports = function (DOMPurify, window, tests, xssTests) {
1420
1390
QUnit . test (
1421
1391
'Test against insecure behavior in jQUery v3.0 and newer 2/2' ,
1422
1392
function ( assert ) {
1423
- var config = {
1424
- SAFE_FOR_JQUERY : true ,
1425
- ADD_TAGS : [ 'noscript' ] ,
1426
- } ;
1393
+ var config = { } ;
1427
1394
var clean = DOMPurify . sanitize (
1428
1395
"a<noscript><p id='><noscript /><img src=x onerror=alert(1)>'></noscript>" ,
1429
1396
config
1430
1397
) ;
1431
1398
assert . contains ( clean , [
1432
1399
"a<noscript><p id='><noscript /><img src=x onerror=alert(1)>'></noscript>" , // jsdom
1433
1400
'a<noscript><p></p></noscript>' ,
1401
+ "a<p></p>" ,
1434
1402
"a"
1435
1403
] ) ;
1436
1404
}
0 commit comments