File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -49,23 +49,25 @@ export const configuredXss = new FilterXSS({
4949 } ,
5050 ]
5151
52- const url = new URL ( value )
53-
54- for ( const source of allowedSources ) {
55- if ( ! source . url . test ( url . href ) ) {
56- continue
57- }
52+ try {
53+ const url = new URL ( value )
5854
59- const newSearchParams = new URLSearchParams ( url . searchParams )
60- url . searchParams . forEach ( ( value , key ) => {
61- if ( ! source . allowedParameters . some ( ( param ) => param . test ( `${ key } =${ value } ` ) ) ) {
62- newSearchParams . delete ( key )
55+ for ( const source of allowedSources ) {
56+ if ( ! source . url . test ( url . href ) ) {
57+ continue
6358 }
64- } )
6559
66- url . search = newSearchParams . toString ( )
67- return `${ name } ="${ escapeAttrValue ( url . toString ( ) ) } "`
68- }
60+ const newSearchParams = new URLSearchParams ( url . searchParams )
61+ url . searchParams . forEach ( ( value , key ) => {
62+ if ( ! source . allowedParameters . some ( ( param ) => param . test ( `${ key } =${ value } ` ) ) ) {
63+ newSearchParams . delete ( key )
64+ }
65+ } )
66+
67+ url . search = newSearchParams . toString ( )
68+ return `${ name } ="${ escapeAttrValue ( url . toString ( ) ) } "`
69+ }
70+ } catch { }
6971 }
7072
7173 // For Highlight.JS
You can’t perform that action at this time.
0 commit comments