diff --git a/src/compiler/compile/render_dom/wrappers/Element/index.ts b/src/compiler/compile/render_dom/wrappers/Element/index.ts index a80db84169..033ef85ef4 100644 --- a/src/compiler/compile/render_dom/wrappers/Element/index.ts +++ b/src/compiler/compile/render_dom/wrappers/Element/index.ts @@ -894,7 +894,7 @@ function to_html(wrappers: Array, blo attr.node.chunks.forEach(chunk => { if (chunk.type === 'Text') { - state.quasi.value.raw += chunk.data; + state.quasi.value.raw += escape_html(chunk.data); } else { literal.quasis.push(state.quasi); literal.expressions.push(chunk.manipulate(block)); diff --git a/src/compiler/compile/utils/stringify.ts b/src/compiler/compile/utils/stringify.ts index d042cd43ca..19f6d99673 100644 --- a/src/compiler/compile/utils/stringify.ts +++ b/src/compiler/compile/utils/stringify.ts @@ -12,13 +12,15 @@ export function escape(data: string, { only_escape_at_symbol = false } = {}) { } const escaped = { + '"': '"', + "'": ''', '&': '&', '<': '<', '>': '>', }; export function escape_html(html) { - return String(html).replace(/[&<>]/g, match => escaped[match]); + return String(html).replace(/["'&<>]/g, match => escaped[match]); } export function escape_template(str) { diff --git a/test/runtime/samples/attribute-static-quotemarks/_config.js b/test/runtime/samples/attribute-static-quotemarks/_config.js index 794d01c29f..3d389c2273 100644 --- a/test/runtime/samples/attribute-static-quotemarks/_config.js +++ b/test/runtime/samples/attribute-static-quotemarks/_config.js @@ -1,3 +1,8 @@ export default { - html: `foo` + html: ` + + foo + bar + + ` }; \ No newline at end of file diff --git a/test/runtime/samples/attribute-static-quotemarks/main.svelte b/test/runtime/samples/attribute-static-quotemarks/main.svelte index 5f9c68c53c..e01af9f098 100644 --- a/test/runtime/samples/attribute-static-quotemarks/main.svelte +++ b/test/runtime/samples/attribute-static-quotemarks/main.svelte @@ -1 +1,4 @@ -foo \ No newline at end of file + + foo + bar + \ No newline at end of file