File tree Expand file tree Collapse file tree 1 file changed +14
-1
lines changed Expand file tree Collapse file tree 1 file changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -330,7 +330,20 @@ export function finishView (view) {
330330 } )
331331 // gist
332332 view . find ( 'code[data-gist-id]' ) . each ( ( key , value ) => {
333- if ( $ ( value ) . children ( ) . length === 0 ) { $ ( value ) . gist ( window . viewAjaxCallback ) }
333+ if ( $ ( value ) . children ( ) . length === 0 ) {
334+ // strip HTML tags to avoid stored XSS
335+ const gistid = value . getAttribute ( 'data-gist-id' )
336+ value . setAttribute ( 'data-gist-id' , stripTags ( gistid ) )
337+ const gistfile = value . getAttribute ( 'data-gist-file' )
338+ if ( gistfile ) value . setAttribute ( 'data-gist-file' , stripTags ( gistfile ) )
339+ const gistline = value . getAttribute ( 'data-gist-line' )
340+ if ( gistline ) value . setAttribute ( 'data-gist-line' , stripTags ( gistline ) )
341+ const gisthighlightline = value . getAttribute ( 'data-gist-highlight-line' )
342+ if ( gisthighlightline ) value . setAttribute ( 'data-gist-highlight-line' , stripTags ( gisthighlightline ) )
343+ const gistshowloading = value . getAttribute ( 'data-gist-show-loading' )
344+ if ( gistshowloading ) value . setAttribute ( 'data-gist-show-loading' , stripTags ( gistshowloading ) )
345+ $ ( value ) . gist ( window . viewAjaxCallback )
346+ }
334347 } )
335348 // sequence diagram
336349 const sequences = view . find ( 'div.sequence-diagram.raw' ) . removeClass ( 'raw' )
You can’t perform that action at this time.
0 commit comments