File tree Expand file tree Collapse file tree 3 files changed +21
-4
lines changed
packages/scratch-svg-renderer Expand file tree Collapse file tree 3 files changed +21
-4
lines changed Original file line number Diff line number Diff line change @@ -18,7 +18,7 @@ DOMPurify.addHook(
1818 const href = currentNode . href . baseVal . replace ( / \s / g, '' ) ;
1919 // "data:" and "#" are valid hrefs
2020 if ( ! isInternalRef ( href ) ) {
21-
21+ // TODO: Those can be in different namespaces than `xlink:`
2222 if ( currentNode . attributes . getNamedItem ( 'xlink:href' ) ) {
2323 currentNode . attributes . removeNamedItem ( 'xlink:href' ) ;
2424 delete currentNode [ 'xlink:href' ] ;
@@ -67,16 +67,21 @@ DOMPurify.addHook(
6767
6868 // Elements using url(...) for external resources
6969 if ( astNode . type === 'Declaration' && astNode . value ) {
70+ let shouldRemove = false ;
7071 walk ( astNode . value , valueNode => {
7172 if ( valueNode . type === 'Url' ) {
7273 const urlValue = ( valueNode . value . value || '' ) . trim ( ) . replace ( / [ ' " ] / g, '' ) ;
7374
7475 if ( ! isInternalRef ( urlValue ) ) {
75- list . remove ( item ) ;
76- isModified = true ;
76+ shouldRemove = true ;
7777 }
7878 }
7979 } ) ;
80+
81+ if ( shouldRemove ) {
82+ list . remove ( item ) ;
83+ isModified = true ;
84+ }
8085 }
8186 } ) ;
8287
You can’t perform that action at this time.
0 commit comments