Skip to content

Commit cbafeba

Browse files
authored
Test U+0000 in bogus comment and bogus doctype states
Follows whatwg/html#2939
1 parent 9314ef7 commit cbafeba

File tree

3 files changed

+148
-16
lines changed

3 files changed

+148
-16
lines changed

tokenizer/test3.test

Lines changed: 146 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,8 @@
141141
"input":"<!\u0000",
142142
"output":[["Comment", "\uFFFD"]],
143143
"errors":[
144-
{ "code": "incorrectly-opened-comment", "line": 1, "col": 3 }
144+
{ "code": "incorrectly-opened-comment", "line": 1, "col": 3 },
145+
{ "code": "unexpected-null-character", "line": 1, "col": 3 }
145146
]},
146147

147148
{"description":"<!\\u0009",
@@ -180,6 +181,14 @@
180181
{ "code": "incorrectly-opened-comment", "line": 1, "col": 3 }
181182
]},
182183

184+
{"description":"<! \\u0000",
185+
"input":"<! \u0000",
186+
"output":[["Comment", " \uFFFD"]],
187+
"errors":[
188+
{ "code": "incorrectly-opened-comment", "line": 1, "col": 3 },
189+
{ "code": "unexpected-null-character", "line": 1, "col": 4 }
190+
]},
191+
183192
{"description":"<!!",
184193
"input":"<!!",
185194
"output":[["Comment", "!"]],
@@ -1887,7 +1896,8 @@
18871896
"input":"<!DOCTYPE a \u0000",
18881897
"output":[["DOCTYPE", "a", null, null, false]],
18891898
"errors":[
1890-
{ "code": "invalid-character-sequence-after-doctype-name", "line": 1, "col": 13 }
1899+
{ "code": "invalid-character-sequence-after-doctype-name", "line": 1, "col": 13 },
1900+
{ "code": "unexpected-null-character", "line": 1, "col": 13 }
18911901
]},
18921902

18931903
{"description":"<!DOCTYPE a \\u0008",
@@ -2069,7 +2079,8 @@
20692079
"input":"<!DOCTYPE a PUBLIC\u0000",
20702080
"output":[["DOCTYPE", "a", null, null, false]],
20712081
"errors": [
2072-
{ "code": "missing-quote-before-doctype-public-identifier", "col": 19, "line": 1 }
2082+
{ "code": "missing-quote-before-doctype-public-identifier", "col": 19, "line": 1 },
2083+
{ "code": "unexpected-null-character", "line": 1, "col": 19 }
20732084
]},
20742085

20752086
{"description":"<!DOCTYPE a PUBLIC\\u0008",
@@ -2213,6 +2224,24 @@
22132224
{ "code": "eof-in-doctype", "col": 21, "line": 1 }
22142225
]},
22152226

2227+
{"description":"<!DOCTYPE a PUBLIC\"\"\\u0000",
2228+
"input":"<!DOCTYPE a PUBLIC\"\"\u0000",
2229+
"output":[["DOCTYPE", "a", "", null, false]],
2230+
"errors": [
2231+
{ "code": "missing-whitespace-after-doctype-public-keyword", "col": 19, "line": 1 },
2232+
{ "code": "missing-quote-before-doctype-system-identifier", "col": 21, "line": 1 },
2233+
{ "code": "unexpected-null-character", "col": 21, "line": 1 }
2234+
]},
2235+
2236+
{"description":"<!DOCTYPE a PUBLIC\"\" \\u0000",
2237+
"input":"<!DOCTYPE a PUBLIC\"\" \u0000",
2238+
"output":[["DOCTYPE", "a", "", null, false]],
2239+
"errors": [
2240+
{ "code": "missing-whitespace-after-doctype-public-keyword", "col": 19, "line": 1 },
2241+
{ "code": "missing-quote-before-doctype-system-identifier", "col": 22, "line": 1 },
2242+
{ "code": "unexpected-null-character", "col": 22, "line": 1 }
2243+
]},
2244+
22162245
{"description":"<!DOCTYPE a PUBLIC\"#",
22172246
"input":"<!DOCTYPE a PUBLIC\"#",
22182247
"output":[["DOCTYPE", "a", "#", null, false]],
@@ -2514,7 +2543,8 @@
25142543
"output":[["DOCTYPE", "a", "", null, false]],
25152544
"errors": [
25162545
{ "code": "missing-whitespace-after-doctype-public-keyword", "col": 19, "line": 1 },
2517-
{ "code": "missing-quote-before-doctype-system-identifier", "col": 21, "line": 1 }
2546+
{ "code": "missing-quote-before-doctype-system-identifier", "col": 21, "line": 1 },
2547+
{ "code": "unexpected-null-character", "line": 1, "col": 21 }
25182548
]},
25192549

25202550
{"description":"<!DOCTYPE a PUBLIC''\\u0008",
@@ -2626,6 +2656,46 @@
26262656
{ "code": "eof-in-doctype", "col": 22, "line": 1 }
26272657
]},
26282658

2659+
{"description":"<!DOCTYPE a PUBLIC''''\\u0000",
2660+
"input":"<!DOCTYPE a PUBLIC''''\u0000",
2661+
"output":[["DOCTYPE", "a", "", "", true]],
2662+
"errors": [
2663+
{ "code": "missing-whitespace-after-doctype-public-keyword", "col": 19, "line": 1 },
2664+
{ "code": "missing-whitespace-between-doctype-public-and-system-identifiers", "col": 21, "line": 1 },
2665+
{ "code": "unexpected-character-after-doctype-system-identifier", "line": 1, "col": 23 },
2666+
{ "code": "unexpected-null-character", "line": 1, "col": 23 }
2667+
]},
2668+
2669+
{"description":"<!DOCTYPE a PUBLIC''''x\\u0000",
2670+
"input":"<!DOCTYPE a PUBLIC''''x\u0000",
2671+
"output":[["DOCTYPE", "a", "", "", true]],
2672+
"errors": [
2673+
{ "code": "missing-whitespace-after-doctype-public-keyword", "col": 19, "line": 1 },
2674+
{ "code": "missing-whitespace-between-doctype-public-and-system-identifiers", "col": 21, "line": 1 },
2675+
{ "code": "unexpected-character-after-doctype-system-identifier", "line": 1, "col": 23 },
2676+
{ "code": "unexpected-null-character", "line": 1, "col": 24 }
2677+
]},
2678+
2679+
{"description":"<!DOCTYPE a PUBLIC'''' \\u0000",
2680+
"input":"<!DOCTYPE a PUBLIC'''' \u0000",
2681+
"output":[["DOCTYPE", "a", "", "", true]],
2682+
"errors": [
2683+
{ "code": "missing-whitespace-after-doctype-public-keyword", "col": 19, "line": 1 },
2684+
{ "code": "missing-whitespace-between-doctype-public-and-system-identifiers", "col": 21, "line": 1 },
2685+
{ "code": "unexpected-character-after-doctype-system-identifier", "line": 1, "col": 24 },
2686+
{ "code": "unexpected-null-character", "line": 1, "col": 24 }
2687+
]},
2688+
2689+
{"description":"<!DOCTYPE a PUBLIC'''' x\\u0000",
2690+
"input":"<!DOCTYPE a PUBLIC'''' x\u0000",
2691+
"output":[["DOCTYPE", "a", "", "", true]],
2692+
"errors": [
2693+
{ "code": "missing-whitespace-after-doctype-public-keyword", "col": 19, "line": 1 },
2694+
{ "code": "missing-whitespace-between-doctype-public-and-system-identifiers", "col": 21, "line": 1 },
2695+
{ "code": "unexpected-character-after-doctype-system-identifier", "line": 1, "col": 24 },
2696+
{ "code": "unexpected-null-character", "line": 1, "col": 25 }
2697+
]},
2698+
26292699
{"description":"<!DOCTYPE a PUBLIC''(",
26302700
"input":"<!DOCTYPE a PUBLIC''(",
26312701
"output":[["DOCTYPE", "a", "", null, false]],
@@ -3142,7 +3212,24 @@
31423212
"input":"<!DOCTYPE a SYSTEM\u0000",
31433213
"output":[["DOCTYPE", "a", null, null, false]],
31443214
"errors": [
3145-
{ "code": "missing-quote-before-doctype-system-identifier", "col": 19, "line": 1 }
3215+
{ "code": "missing-quote-before-doctype-system-identifier", "col": 19, "line": 1 },
3216+
{ "code": "unexpected-null-character", "line": 1, "col": 19 }
3217+
]},
3218+
3219+
{"description":"<!DOCTYPE a SYSTEM \\u0000",
3220+
"input":"<!DOCTYPE a SYSTEM \u0000",
3221+
"output":[["DOCTYPE", "a", null, null, false]],
3222+
"errors": [
3223+
{ "code": "missing-quote-before-doctype-system-identifier", "col": 20, "line": 1 },
3224+
{ "code": "unexpected-null-character", "line": 1, "col": 20 }
3225+
]},
3226+
3227+
{"description":"<!DOCTYPE a SYSTEM x\\u0000",
3228+
"input":"<!DOCTYPE a SYSTEM \u0000",
3229+
"output":[["DOCTYPE", "a", null, null, false]],
3230+
"errors": [
3231+
{ "code": "missing-quote-before-doctype-system-identifier", "col": 20, "line": 1 },
3232+
{ "code": "unexpected-null-character", "line": 1, "col": 20 }
31463233
]},
31473234

31483235
{"description":"<!DOCTYPE a SYSTEM\\u0008",
@@ -3586,7 +3673,8 @@
35863673
"output":[["DOCTYPE", "a", null, "", true]],
35873674
"errors":[
35883675
{ "code": "missing-whitespace-after-doctype-system-keyword", "line": 1, "col": 19 },
3589-
{ "code": "unexpected-character-after-doctype-system-identifier", "col": 21, "line": 1 }
3676+
{ "code": "unexpected-character-after-doctype-system-identifier", "col": 21, "line": 1 },
3677+
{ "code": "unexpected-null-character", "line": 1, "col": 21 }
35903678
]},
35913679

35923680
{"description":"<!DOCTYPE a SYSTEM''\\u0008",
@@ -3656,6 +3744,24 @@
36563744
{ "code": "eof-in-doctype", "col": 22, "line": 1 }
36573745
]},
36583746

3747+
{"description":"<!DOCTYPE a SYSTEM'' \\u0000",
3748+
"input":"<!DOCTYPE a SYSTEM'' \u0000",
3749+
"output":[["DOCTYPE", "a", null, "", true]],
3750+
"errors":[
3751+
{ "code": "missing-whitespace-after-doctype-system-keyword", "line": 1, "col": 19 },
3752+
{ "code": "unexpected-character-after-doctype-system-identifier", "col": 22, "line": 1 },
3753+
{ "code": "unexpected-null-character", "line": 1, "col": 22 }
3754+
]},
3755+
3756+
{"description":"<!DOCTYPE a SYSTEM'' x\\u0000",
3757+
"input":"<!DOCTYPE a SYSTEM'' x\u0000",
3758+
"output":[["DOCTYPE", "a", null, "", true]],
3759+
"errors":[
3760+
{ "code": "missing-whitespace-after-doctype-system-keyword", "line": 1, "col": 19 },
3761+
{ "code": "unexpected-character-after-doctype-system-identifier", "col": 22, "line": 1 },
3762+
{ "code": "unexpected-null-character", "line": 1, "col": 23 }
3763+
]},
3764+
36593765
{"description":"<!DOCTYPE a SYSTEM''!",
36603766
"input":"<!DOCTYPE a SYSTEM''!",
36613767
"output":[["DOCTYPE", "a", null, "", true]],
@@ -4217,7 +4323,8 @@
42174323
"input":"<!DOCTYPE a a\u0000",
42184324
"output":[["DOCTYPE", "a", null, null, false]],
42194325
"errors":[
4220-
{ "code": "invalid-character-sequence-after-doctype-name", "line": 1, "col": 13 }
4326+
{ "code": "invalid-character-sequence-after-doctype-name", "line": 1, "col": 13 },
4327+
{ "code": "unexpected-null-character", "line": 1, "col": 14 }
42214328
]},
42224329

42234330
{"description":"<!DOCTYPE a a\\u0009",
@@ -4920,7 +5027,8 @@
49205027
"output":[["DOCTYPE", "a", null, null, false]],
49215028
"errors":[
49225029
{ "code": "missing-whitespace-before-doctype-name", "line": 1, "col": 10 },
4923-
{ "code": "invalid-character-sequence-after-doctype-name", "line": 1, "col": 12 }
5030+
{ "code": "invalid-character-sequence-after-doctype-name", "line": 1, "col": 12 },
5031+
{ "code": "unexpected-null-character", "line": 1, "col": 12 }
49245032
]},
49255033

49265034
{"description":"<!DOCTYPEa \\u0008",
@@ -5130,7 +5238,8 @@
51305238
"output":[["DOCTYPE", "a", null, null, false]],
51315239
"errors":[
51325240
{ "code": "missing-whitespace-before-doctype-name", "line": 1, "col": 10 },
5133-
{ "code": "missing-quote-before-doctype-public-identifier", "line": 1, "col": 18 }
5241+
{ "code": "missing-quote-before-doctype-public-identifier", "line": 1, "col": 18 },
5242+
{ "code": "unexpected-null-character", "line": 1, "col": 18 }
51345243
]},
51355244

51365245
{"description":"<!DOCTYPEa PUBLIC\\u0008",
@@ -5632,7 +5741,8 @@
56325741
"errors":[
56335742
{ "code": "missing-whitespace-before-doctype-name", "line": 1, "col": 10 },
56345743
{ "code": "missing-whitespace-after-doctype-public-keyword", "line": 1, "col": 18 },
5635-
{ "code": "missing-quote-before-doctype-system-identifier", "line": 1, "col": 20 }
5744+
{ "code": "missing-quote-before-doctype-system-identifier", "line": 1, "col": 20 },
5745+
{ "code": "unexpected-null-character", "line": 1, "col": 20 }
56365746
]},
56375747

56385748
{"description":"<!DOCTYPEa PUBLIC''\\u0008",
@@ -6341,7 +6451,8 @@
63416451
"output":[["DOCTYPE", "a", null, null, false]],
63426452
"errors":[
63436453
{ "code": "missing-whitespace-before-doctype-name", "line": 1, "col": 10 },
6344-
{ "code": "missing-quote-before-doctype-system-identifier", "line": 1, "col": 18 }
6454+
{ "code": "missing-quote-before-doctype-system-identifier", "line": 1, "col": 18 },
6455+
{ "code": "unexpected-null-character", "line": 1, "col": 18 }
63456456
]},
63466457

63476458
{"description":"<!DOCTYPEa SYSTEM\\u0008",
@@ -6842,7 +6953,8 @@
68426953
"errors":[
68436954
{ "code": "missing-whitespace-before-doctype-name", "line": 1, "col": 10 },
68446955
{ "code": "missing-whitespace-after-doctype-system-keyword", "line": 1, "col": 18 },
6845-
{ "code": "unexpected-character-after-doctype-system-identifier", "line": 1, "col": 20 }
6956+
{ "code": "unexpected-character-after-doctype-system-identifier", "line": 1, "col": 20 },
6957+
{ "code": "unexpected-null-character", "line": 1, "col": 20 }
68466958
]},
68476959

68486960
{"description":"<!DOCTYPEa SYSTEM''\\u0008",
@@ -7555,7 +7667,8 @@
75557667
"output":[["DOCTYPE", "a", null, null, false]],
75567668
"errors":[
75577669
{ "code": "missing-whitespace-before-doctype-name", "line": 1, "col": 10 },
7558-
{ "code": "invalid-character-sequence-after-doctype-name", "line": 1, "col": 12 }
7670+
{ "code": "invalid-character-sequence-after-doctype-name", "line": 1, "col": 12 },
7671+
{ "code": "unexpected-null-character", "line": 1, "col": 13 }
75597672
]},
75607673

75617674
{"description":"<!DOCTYPEa a\\u0009",
@@ -8195,7 +8308,8 @@
81958308
"input":"</\u0000",
81968309
"output":[["Comment", "\uFFFD"]],
81978310
"errors":[
8198-
{ "code": "invalid-first-character-of-tag-name", "line": 1, "col": 3 }
8311+
{ "code": "invalid-first-character-of-tag-name", "line": 1, "col": 3 },
8312+
{ "code": "unexpected-null-character", "line": 1, "col": 3 }
81998313
]},
82008314

82018315
{"description":"</\\u0009",
@@ -8234,6 +8348,14 @@
82348348
{ "code": "invalid-first-character-of-tag-name", "line": 1, "col": 3 }
82358349
]},
82368350

8351+
{"description":"</ \\u0000",
8352+
"input":"</ \u0000",
8353+
"output":[["Comment", " \uFFFD"]],
8354+
"errors":[
8355+
{ "code": "invalid-first-character-of-tag-name", "line": 1, "col": 3 },
8356+
{ "code": "unexpected-null-character", "line": 1, "col": 4 }
8357+
]},
8358+
82378359
{"description":"</!",
82388360
"input":"</!",
82398361
"output":[["Comment", "!"]],
@@ -8446,7 +8568,8 @@
84468568
"input":"<?\u0000",
84478569
"output":[["Comment", "?\uFFFD"]],
84488570
"errors":[
8449-
{ "code": "unexpected-question-mark-instead-of-tag-name", "line": 1, "col": 2 }
8571+
{ "code": "unexpected-question-mark-instead-of-tag-name", "line": 1, "col": 2 },
8572+
{ "code": "unexpected-null-character", "line": 1, "col": 3 }
84508573
]},
84518574

84528575
{"description":"<?\\u0009",
@@ -8485,6 +8608,14 @@
84858608
{ "code": "unexpected-question-mark-instead-of-tag-name", "line": 1, "col": 2 }
84868609
]},
84878610

8611+
{"description":"<? \\u0000",
8612+
"input":"<? \u0000",
8613+
"output":[["Comment", "? \uFFFD"]],
8614+
"errors":[
8615+
{ "code": "unexpected-question-mark-instead-of-tag-name", "line": 1, "col": 2 },
8616+
{ "code": "unexpected-null-character", "line": 1, "col": 4 }
8617+
]},
8618+
84888619
{"description":"<?!",
84898620
"input":"<?!",
84908621
"output":[["Comment", "?!"]],

tokenizer/test4.test

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,8 @@
364364
"input":"<!doc\u0000",
365365
"output":[["Comment", "doc\uFFFD"]],
366366
"errors":[
367-
{ "code": "incorrectly-opened-comment", "line": 1, "col": 3 }
367+
{ "code": "incorrectly-opened-comment", "line": 1, "col": 3 },
368+
{ "code": "unexpected-null-character", "line": 1, "col": 6 }
368369
]},
369370

370371
{"description":"U+0080 in lookahead region",
97 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)