@@ -10,6 +10,7 @@ const md = `\
10
10
[XSS](vbscript:alert(document.domain))
11
11
<javascript:prompt(document.cookie)>
12
12
[x](y '<style>')
13
+ <a href="jav	ascript:alert('XSS');">Click Me</a>
13
14
14
15
<!-- image -->
15
16
@@ -31,7 +32,7 @@ const md = `\
31
32
32
33
` . trim ( )
33
34
34
- it ( 'XSS' , async ( ) => {
35
+ it ( 'XSS generic payloads ' , async ( ) => {
35
36
const { data, body } = await parseMarkdown ( md )
36
37
37
38
expect ( Object . keys ( data ) ) . toHaveLength ( 2 )
@@ -41,3 +42,29 @@ it('XSS', async () => {
41
42
expect ( Object . entries ( props as Record < string , any > ) . every ( ( [ k , v ] ) => validateProp ( k , v ) ) ) . toBeTruthy ( )
42
43
}
43
44
} )
45
+
46
+ it ( 'XSS payloads with HTML entities should be caught' , async ( ) => {
47
+ const md = `\
48
+ ## XSS payloads with HTML entities
49
+ <a href="jav	ascript:alert('XSS');">Click Me 1</a>
50
+ <a href="jav
ascript:alert('XSS');">Click Me 2</a>
51
+ <a href="jav ascript:alert('XSS');">Click Me 3</a>
52
+
53
+
54
+ ` . trim ( )
55
+
56
+ // set the number of assertions to expect
57
+ expect . assertions ( 4 )
58
+
59
+ const { data, body } = await parseMarkdown ( md )
60
+
61
+ expect ( Object . keys ( data ) ) . toHaveLength ( 2 )
62
+
63
+ for ( const node of ( body . children [ 1 ] as MDCElement ) . children ) {
64
+ const props = ( node as MDCElement ) . props || { }
65
+
66
+ if ( ( node as MDCElement ) . tag === 'a' ) {
67
+ expect ( Object . keys ( props ) ) . toHaveLength ( 0 )
68
+ }
69
+ }
70
+ } )
0 commit comments