Skip to content

Commit f0bd250

Browse files
committed
Break out XSS tests and add more.
1 parent e3a1bb0 commit f0bd250

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

test/core.js

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ test( "jQuery(html, props)", function() {
1212
});
1313

1414
test( "jQuery(html) loose rules", function() {
15-
expect( 28 );
15+
expect( 24 );
1616

1717
var w,
1818
nowarns = {
@@ -42,6 +42,10 @@ test( "jQuery(html) loose rules", function() {
4242
for ( w in warns ) {
4343
expectWarning( w, generate( warns[w] ) );
4444
}
45+
});
46+
47+
test( "XSS injection", function() {
48+
expect( 7 );
4549

4650
// Bad HTML will throw on some supported versions
4751
expectWarning( "leading hash", function() {
@@ -52,7 +56,20 @@ test( "jQuery(html) loose rules", function() {
5256

5357
// Don't expect HTML if there's a leading hash char; this is
5458
// more strict than the 1.7 version but closes an XSS hole.
55-
expectWarning( "XSS check", function() {
59+
60+
expectWarning( "XSS via script tag", function() {
61+
var threw = false;
62+
window.XSS = false;
63+
try {
64+
jQuery( "#<script>window.XSS=true<" + "/script>" );
65+
} catch ( e ) {
66+
threw = true;
67+
}
68+
equal( threw, true, "Throw on leading-hash HTML (treated as selector)" );
69+
equal( window.XSS, false, "XSS" );
70+
});
71+
72+
expectWarning( "XSS via onerror inline handler", function() {
5673
var threw = false;
5774
window.XSS = false;
5875
try {

0 commit comments

Comments
 (0)