File tree Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -54,4 +54,27 @@ describe('Default HTML filtering', () => {
54
54
expect ( value ) . to . contain ( 'title' ) ;
55
55
} ) ;
56
56
} ) ;
57
+
58
+ it ( 'rejects invalid protocol links' , ( ) => {
59
+ const text = '<p>This is an <a href="javascript://%0aalert(document.location)">xss test</a></p>' ;
60
+ modifyContent ( path , text ) ;
61
+ getContent ( path ) . then ( result => {
62
+ const value = result . data . jcr . nodeByPath . property . value ;
63
+ expect ( value ) . to . contain ( '<p>' ) ;
64
+ expect ( value ) . to . not . contain ( '<a' ) ;
65
+ expect ( value ) . to . not . contain ( 'href' ) ;
66
+ } ) ;
67
+ } ) ;
68
+
69
+ it ( 'rejects invalid href links' , ( ) => {
70
+ const text = '<p>This is an <a href="#javascript:alert(\'hello\')" target="_blank">xss test</a></p>' ;
71
+ modifyContent ( path , text ) ;
72
+ getContent ( path ) . then ( result => {
73
+ const value = result . data . jcr . nodeByPath . property . value ;
74
+ expect ( value ) . to . contain ( '<p>' ) ;
75
+ expect ( value ) . to . contain ( '<a' ) ;
76
+ expect ( value ) . to . not . contain ( 'href' ) ;
77
+ expect ( value ) . to . contain ( 'target' ) ;
78
+ } ) ;
79
+ } ) ;
57
80
} ) ;
You can’t perform that action at this time.
0 commit comments