From e96be8f84f4de8996c1b195df0147b38468a67d3 Mon Sep 17 00:00:00 2001 From: Thomas Ghysels Date: Sat, 22 Jun 2019 15:34:41 +0200 Subject: [PATCH] Fix ambiguous entities Fix sveltejs/sapper/issues/759 --- src/compiler/parse/utils/html.ts | 2 +- test/parser/samples/attribute-escaped/input.svelte | 2 +- test/parser/samples/attribute-escaped/output.json | 12 ++++++------ test/runtime/samples/html-entities/_config.js | 2 +- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/compiler/parse/utils/html.ts b/src/compiler/parse/utils/html.ts index b49989eacd36..13ff553a3f20 100644 --- a/src/compiler/parse/utils/html.ts +++ b/src/compiler/parse/utils/html.ts @@ -36,7 +36,7 @@ const windows_1252 = [ ]; const entity_pattern = new RegExp( - `&(#?(?:x[\\w\\d]+|\\d+|${Object.keys(entities).join('|')}));?`, + `&(#?(?:x[\\w\\d]+|\\d+|${Object.keys(entities).join('|')}))(?:;|\\b)`, 'g' ); diff --git a/test/parser/samples/attribute-escaped/input.svelte b/test/parser/samples/attribute-escaped/input.svelte index 82186dcee47b..4c9cd5ff6885 100644 --- a/test/parser/samples/attribute-escaped/input.svelte +++ b/test/parser/samples/attribute-escaped/input.svelte @@ -1 +1 @@ -
+
diff --git a/test/parser/samples/attribute-escaped/output.json b/test/parser/samples/attribute-escaped/output.json index e60a8c253189..ef6821752b62 100644 --- a/test/parser/samples/attribute-escaped/output.json +++ b/test/parser/samples/attribute-escaped/output.json @@ -1,27 +1,27 @@ { "html": { "start": 0, - "end": 41, + "end": 82, "type": "Fragment", "children": [ { "start": 0, - "end": 41, + "end": 78, "type": "Element", "name": "div", "attributes": [ { "start": 5, - "end": 34, + "end": 75, "type": "Attribute", "name": "data-foo", "value": [ { "start": 15, - "end": 33, + "end": 74, "type": "Text", - "raw": ""quoted"", - "data": "\"quoted\"" + "raw": "semi:"space:" letter:"e number:"1 end:"", + "data": "semi:\"space:\" letter:"e number:"1 end:\"" } ] } diff --git a/test/runtime/samples/html-entities/_config.js b/test/runtime/samples/html-entities/_config.js index 1591f31a5362..c8c2de84036c 100644 --- a/test/runtime/samples/html-entities/_config.js +++ b/test/runtime/samples/html-entities/_config.js @@ -9,6 +9,6 @@ export default { A - ¬anentity; + &notanentity; ` }; \ No newline at end of file