File tree Expand file tree Collapse file tree 1 file changed +9
-4
lines changed
Expand file tree Collapse file tree 1 file changed +9
-4
lines changed Original file line number Diff line number Diff line change @@ -552,17 +552,22 @@ export function finishView (view) {
552552 } catch ( err ) {
553553 console . warn ( err )
554554 }
555- // unescape > symbel inside the style tags
556- view . find ( 'style' ) . each ( ( key , value ) => {
557- $ ( value ) . html ( $ ( value ) . html ( ) . replace ( / & g t ; / g, '>' ) )
558- } )
559555 // render title
560556 document . title = renderTitle ( view )
561557}
562558
563559// only static transform should be here
564560export function postProcess ( code ) {
565561 const result = $ ( `<div>${ code } </div>` )
562+ // process style tags
563+ result . find ( 'style' ) . each ( ( key , value ) => {
564+ let html = $ ( value ) . html ( )
565+ // unescape > symbel inside the style tags
566+ html = html . replace ( / & g t ; / g, '>' )
567+ // remove css @import to prevent XSS
568+ html = html . replace ( / @ i m p o r t u r l \( ( [ ^ ) ] * ) \) ; ? / gi, '' )
569+ $ ( value ) . html ( html )
570+ } )
566571 // link should open in new window or tab
567572 result . find ( 'a:not([href^="#"]):not([target])' ) . attr ( 'target' , '_blank' )
568573 // update continue line numbers
You can’t perform that action at this time.
0 commit comments