Skip to content

Commit 1b9926b

Browse files
committedJun 22, 2019
Fix ambiguous entities
Fix sveltejs/sapper/issues/759
1 parent fee4d35 commit 1b9926b

File tree

4 files changed

+9
-9
lines changed

4 files changed

+9
-9
lines changed
 

‎src/compiler/parse/utils/html.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ const windows_1252 = [
3636
];
3737

3838
const entity_pattern = new RegExp(
39-
`&(#?(?:x[\\w\\d]+|\\d+|${Object.keys(entities).join('|')}));?`,
39+
`&(#?(?:x[\\w\\d]+|\\d+|${Object.keys(entities).join('|')}))(?:;|\\b)`,
4040
'g'
4141
);
4242

Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
<div data-foo='&quot;quoted&quot;'></div>
1+
<div data-foo='semi:&quot;space:&quot letter:&quote number:&quot1 end:&quot'></div>

‎test/parser/samples/attribute-escaped/output.json

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,27 @@
11
{
22
"html": {
33
"start": 0,
4-
"end": 41,
4+
"end": 83,
55
"type": "Fragment",
66
"children": [
77
{
88
"start": 0,
9-
"end": 41,
9+
"end": 83,
1010
"type": "Element",
1111
"name": "div",
1212
"attributes": [
1313
{
1414
"start": 5,
15-
"end": 34,
15+
"end": 76,
1616
"type": "Attribute",
1717
"name": "data-foo",
1818
"value": [
1919
{
2020
"start": 15,
21-
"end": 33,
21+
"end": 75,
2222
"type": "Text",
23-
"raw": "&quot;quoted&quot;",
24-
"data": "\"quoted\""
23+
"raw": "semi:&quot;space:&quot letter:&quote number:&quot1 end:&quot",
24+
"data": "semi:\"space:\" letter:&quote number:&quot1 end:\""
2525
}
2626
]
2727
}

‎test/runtime/samples/html-entities/_config.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@ export default {
99
<span>A</span>
1010
<span>€</span>
1111
12-
<span>&notanentity;</span>
12+
<span>&amp;notanentity;</span>
1313
`
1414
};

0 commit comments

Comments
 (0)