File tree Expand file tree Collapse file tree 6 files changed +43
-1
lines changed
inline-style-directive-escape Expand file tree Collapse file tree 6 files changed +43
-1
lines changed Original file line number Diff line number Diff line change @@ -205,7 +205,7 @@ export function add_classes(classes) {
205205function style_object_to_string ( style_object ) {
206206 return Object . keys ( style_object )
207207 . filter ( key => style_object [ key ] )
208- . map ( key => `${ key } : ${ style_object [ key ] } ;` )
208+ . map ( key => `${ key } : ${ escape_attribute_value ( style_object [ key ] ) } ;` )
209209 . join ( ' ' ) ;
210210}
211211
Original file line number Diff line number Diff line change 1+ <div >hi</div >
2+
3+ <style >
4+ div {
5+ background-color : var (--color );
6+ }
7+ </style >
Original file line number Diff line number Diff line change 1+ export default {
2+ html : `
3+ <div style="display: contents; --color: " onload="alert('uhoh')" data-nothing="not important;">
4+ <div class="svelte-271qee">hi</div>
5+ </div>
6+ ` ,
7+ ssrHtml : `
8+ <div style="display: contents; --color:" onload="alert('uhoh')" data-nothing="not important;">
9+ <div class="svelte-271qee">hi</div>
10+ </div>
11+ `
12+ } ;
Original file line number Diff line number Diff line change 1+ <script >
2+ import Sub from ' ./Sub.svelte' ;
3+ export let attack = ' " onload="alert(\' uhoh\' )" data-nothing="not important' ;
4+ </script >
5+
6+ <Sub --color ={attack } />
Original file line number Diff line number Diff line change 1+ export default {
2+ html : `
3+ <div style="--css-variable: " onload="alert('uhoh')" data-nothing="not important;"></div>
4+ ` ,
5+
6+ test ( { assert, component, target } ) {
7+ component . attack = '" onload="alert(\'uhoh2\')" data-nothing="not important' ;
8+ assert . htmlEqual ( target . innerHTML , `
9+ <div style="--css-variable: " onload="alert('uhoh2')" data-nothing="not important;"></div>
10+ ` ) ;
11+ }
12+ } ;
Original file line number Diff line number Diff line change 1+ <script >
2+ export let attack = ' " onload="alert(\' uhoh\' )" data-nothing="not important' ;
3+ </script >
4+
5+ <div style:--css-variable ={attack } />
You can’t perform that action at this time.
0 commit comments