Skip to content

Commit 52e42e8

Browse files
committed
Fix: bugs about control character reference mapping
1 parent 6209fc0 commit 52e42e8

File tree

5 files changed

+303
-4
lines changed

5 files changed

+303
-4
lines changed

.vscode/settings.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,5 @@
44
{"language": "html", "autoFix": true},
55
{"language": "vue", "autoFix": true},
66
{"language": "typescript", "autoFix": true}
7-
],
8-
"files.insertFinalNewline": false
7+
]
98
}

src/html/tokenizer.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1690,8 +1690,6 @@ export class Tokenizer {
16901690
}
16911691
else if (code === 0x0D || (isControl(code) && !isWhitespace(code))) {
16921692
this.reportParseError("control-character-reference")
1693-
}
1694-
else if (code >= 0x80 && code <= 0x9F) {
16951693
code = alternativeCR.get(code) || code
16961694
}
16971695

Lines changed: 289 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,289 @@
1+
{
2+
"type": "Program",
3+
"start": 0,
4+
"end": 0,
5+
"loc": {
6+
"start": {
7+
"line": 1,
8+
"column": 0
9+
},
10+
"end": {
11+
"line": 1,
12+
"column": 0
13+
}
14+
},
15+
"range": [
16+
0,
17+
0
18+
],
19+
"body": [],
20+
"sourceType": "script",
21+
"comments": [],
22+
"tokens": [],
23+
"templateBody": {
24+
"type": "VElement",
25+
"range": [
26+
0,
27+
39
28+
],
29+
"loc": {
30+
"start": {
31+
"line": 1,
32+
"column": 0
33+
},
34+
"end": {
35+
"line": 1,
36+
"column": 39
37+
}
38+
},
39+
"name": "template",
40+
"namespace": "http://www.w3.org/1999/xhtml",
41+
"startTag": {
42+
"type": "VStartTag",
43+
"range": [
44+
0,
45+
10
46+
],
47+
"loc": {
48+
"start": {
49+
"line": 1,
50+
"column": 0
51+
},
52+
"end": {
53+
"line": 1,
54+
"column": 10
55+
}
56+
},
57+
"attributes": []
58+
},
59+
"children": [
60+
{
61+
"type": "VText",
62+
"range": [
63+
10,
64+
28
65+
],
66+
"loc": {
67+
"start": {
68+
"line": 1,
69+
"column": 10
70+
},
71+
"end": {
72+
"line": 1,
73+
"column": 28
74+
}
75+
},
76+
"value": "€ is €"
77+
}
78+
],
79+
"endTag": {
80+
"type": "VEndTag",
81+
"range": [
82+
28,
83+
39
84+
],
85+
"loc": {
86+
"start": {
87+
"line": 1,
88+
"column": 28
89+
},
90+
"end": {
91+
"line": 1,
92+
"column": 39
93+
}
94+
}
95+
},
96+
"variables": [],
97+
"tokens": [
98+
{
99+
"type": "HTMLTagOpen",
100+
"range": [
101+
0,
102+
9
103+
],
104+
"loc": {
105+
"start": {
106+
"line": 1,
107+
"column": 0
108+
},
109+
"end": {
110+
"line": 1,
111+
"column": 9
112+
}
113+
},
114+
"value": "template"
115+
},
116+
{
117+
"type": "HTMLTagClose",
118+
"range": [
119+
9,
120+
10
121+
],
122+
"loc": {
123+
"start": {
124+
"line": 1,
125+
"column": 9
126+
},
127+
"end": {
128+
"line": 1,
129+
"column": 10
130+
}
131+
},
132+
"value": ""
133+
},
134+
{
135+
"type": "HTMLText",
136+
"range": [
137+
10,
138+
16
139+
],
140+
"loc": {
141+
"start": {
142+
"line": 1,
143+
"column": 10
144+
},
145+
"end": {
146+
"line": 1,
147+
"column": 16
148+
}
149+
},
150+
"value": ""
151+
},
152+
{
153+
"type": "HTMLWhitespace",
154+
"range": [
155+
16,
156+
17
157+
],
158+
"loc": {
159+
"start": {
160+
"line": 1,
161+
"column": 16
162+
},
163+
"end": {
164+
"line": 1,
165+
"column": 17
166+
}
167+
},
168+
"value": " "
169+
},
170+
{
171+
"type": "HTMLText",
172+
"range": [
173+
17,
174+
19
175+
],
176+
"loc": {
177+
"start": {
178+
"line": 1,
179+
"column": 17
180+
},
181+
"end": {
182+
"line": 1,
183+
"column": 19
184+
}
185+
},
186+
"value": "is"
187+
},
188+
{
189+
"type": "HTMLWhitespace",
190+
"range": [
191+
19,
192+
20
193+
],
194+
"loc": {
195+
"start": {
196+
"line": 1,
197+
"column": 19
198+
},
199+
"end": {
200+
"line": 1,
201+
"column": 20
202+
}
203+
},
204+
"value": " "
205+
},
206+
{
207+
"type": "HTMLText",
208+
"range": [
209+
20,
210+
28
211+
],
212+
"loc": {
213+
"start": {
214+
"line": 1,
215+
"column": 20
216+
},
217+
"end": {
218+
"line": 1,
219+
"column": 28
220+
}
221+
},
222+
"value": ""
223+
},
224+
{
225+
"type": "HTMLEndTagOpen",
226+
"range": [
227+
28,
228+
38
229+
],
230+
"loc": {
231+
"start": {
232+
"line": 1,
233+
"column": 28
234+
},
235+
"end": {
236+
"line": 1,
237+
"column": 38
238+
}
239+
},
240+
"value": "template"
241+
},
242+
{
243+
"type": "HTMLTagClose",
244+
"range": [
245+
38,
246+
39
247+
],
248+
"loc": {
249+
"start": {
250+
"line": 1,
251+
"column": 38
252+
},
253+
"end": {
254+
"line": 1,
255+
"column": 39
256+
}
257+
},
258+
"value": ""
259+
},
260+
{
261+
"type": "HTMLWhitespace",
262+
"range": [
263+
39,
264+
40
265+
],
266+
"loc": {
267+
"start": {
268+
"line": 1,
269+
"column": 39
270+
},
271+
"end": {
272+
"line": 2,
273+
"column": 0
274+
}
275+
},
276+
"value": "\n"
277+
}
278+
],
279+
"comments": [],
280+
"errors": [
281+
{
282+
"message": "control-character-reference (1:16)",
283+
"index": 16,
284+
"lineNumber": 1,
285+
"column": 16
286+
}
287+
]
288+
}
289+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<template>&#x80; is &#x20AC;</template>
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
[
2+
"<template",
3+
">",
4+
"&#x80;",
5+
" ",
6+
"is",
7+
" ",
8+
"&#x20AC;",
9+
"</template",
10+
">",
11+
"\n"
12+
]

0 commit comments

Comments
 (0)