Fix parsing ambiguous HTML entities (#3071)

Fixes sveltejs/sapper#759
pull/3086/head
Thomas Ghysels 5 years ago committed by Conduitry
parent 60914b86fd
commit c9e3762638

@ -36,7 +36,7 @@ const windows_1252 = [
]; ];
const entity_pattern = new RegExp( const entity_pattern = new RegExp(
`&(#?(?:x[\\w\\d]+|\\d+|${Object.keys(entities).join('|')}));?`, `&(#?(?:x[\\w\\d]+|\\d+|${Object.keys(entities).join('|')}))(?:;|\\b)`,
'g' 'g'
); );

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

@ -1,27 +1,27 @@
{ {
"html": { "html": {
"start": 0, "start": 0,
"end": 41, "end": 83,
"type": "Fragment", "type": "Fragment",
"children": [ "children": [
{ {
"start": 0, "start": 0,
"end": 41, "end": 83,
"type": "Element", "type": "Element",
"name": "div", "name": "div",
"attributes": [ "attributes": [
{ {
"start": 5, "start": 5,
"end": 34, "end": 76,
"type": "Attribute", "type": "Attribute",
"name": "data-foo", "name": "data-foo",
"value": [ "value": [
{ {
"start": 15, "start": 15,
"end": 33, "end": 75,
"type": "Text", "type": "Text",
"raw": "&quot;quoted&quot;", "raw": "semi:&quot;space:&quot letter:&quote number:&quot1 end:&quot",
"data": "\"quoted\"" "data": "semi:\"space:\" letter:&quote number:&quot1 end:\""
} }
] ]
} }

@ -9,6 +9,6 @@ export default {
<span>A</span> <span>A</span>
<span></span> <span></span>
<span>&notanentity;</span> <span>&amp;notanentity;</span>
` `
}; };
Loading…
Cancel
Save