File tree Expand file tree Collapse file tree 2 files changed +4
-6
lines changed
Expand file tree Collapse file tree 2 files changed +4
-6
lines changed Original file line number Diff line number Diff line change 22" domiso " : patch
33---
44
5- feat: better HTML/XML support, remove ` javascript: ` attributes
5+ feat: better HTML/XML support, remove ` data: ` , ` javascript: ` and ` vbscript :` attributes
Original file line number Diff line number Diff line change @@ -8,8 +8,8 @@ const sanitizeAttributes = (el: Element) => {
88 for ( let i = 0 , len = attrs . length ; i < len ; i ++ ) {
99 const attr = attrs [ i ]
1010 if (
11- attr . name . toLowerCase ( ) . startsWith ( 'on' ) ||
12- attr . value . toLowerCase ( ) . startsWith ( 'javascript:' )
11+ / ^ o n / i . test ( attr . name ) ||
12+ / ^ (?: d a t a | j a v a s c r i p t | v b s c r i p t ) : / i . test ( attr . value )
1313 ) {
1414 el . removeAttributeNode ( attr )
1515 // eslint-disable-next-line sonar/updated-loop-counter -- the attribute is removed, the index and length must be rechecked
@@ -39,9 +39,7 @@ function sanitizeNode(el: Document | Element) {
3939 return sanitizeChildren ( el )
4040 }
4141
42- const tagName = el . tagName . toLowerCase ( )
43-
44- if ( [ 'parsererror' , 'script' ] . includes ( tagName ) ) {
42+ if ( [ 'parsererror' , 'script' ] . includes ( el . tagName . toLowerCase ( ) ) ) {
4543 el . remove ( )
4644 return null
4745 }
You can’t perform that action at this time.
0 commit comments