fix attribute escaping during ssr

pull/7333/head
mrkishi 5 years ago
parent 9b7b8149e4
commit 8e6afff0a1

@ -177,7 +177,8 @@ export function create_ssr_component(fn) {
export function add_attribute(name, value, boolean) {
if (value == null || (boolean && !value)) return '';
return ` ${name}${value === true && boolean_attributes.has(name) ? '' : `=${typeof value === 'string' ? JSON.stringify(escape(value)) : `"${value}"`}`}`;
const assignment = (boolean && value === true) ? '' : `="${escape_attribute_value(value.toString())}"`;
return ` ${name}${assignment}`;
}
export function add_classes(classes) {

@ -1,3 +1,3 @@
<div
foo="&#34;></div><script>alert(42)</script>"
></div>
foo="&#34;></div>\<script>alert(42)</script>"
></div>

@ -1,5 +1,5 @@
<script>
export let foo = '"></div><script>alert(42)</' + 'script>';
export let foo = '"></div>\\<script>alert(42)</' + 'script>';
</script>
<div foo={foo}></div>
Loading…
Cancel
Save