Skip to content

Commit ef63fc9

Browse files
committed
Fix test cases of things that have changed in spec. This implements r2990 ("EOF in tag tokens throws away the token now (for security reasons)") and r3121 ("Reduce the number of parse errors for EOF in DOCTYPE.") of the spec.
1 parent b97af5e commit ef63fc9

File tree

1 file changed

+28
-30
lines changed

1 file changed

+28
-30
lines changed

library/HTML5/Tokenizer.php

+28-30
Original file line numberDiff line numberDiff line change
@@ -582,13 +582,11 @@ public function parse() {
582582

583583
} elseif($char === false) {
584584
/* EOF
585-
Parse error. Emit the current tag token. Reconsume the EOF
586-
character in the data state. */
585+
Parse error. Reconsume the EOF character in the data state. */
587586
$this->emitToken(array(
588587
'type' => self::PARSEERROR,
589588
'data' => 'eof-in-tag-name'
590589
));
591-
$this->emitToken($this->token);
592590

593591
$this->stream->unget();
594592
$state = 'data';
@@ -644,13 +642,11 @@ public function parse() {
644642

645643
} elseif($char === false) {
646644
/* EOF
647-
Parse error. Emit the current tag token. Reconsume the EOF
648-
character in the data state. */
645+
Parse error. Reconsume the EOF character in the data state. */
649646
$this->emitToken(array(
650647
'type' => self::PARSEERROR,
651648
'data' => 'expected-attribute-name-but-got-eof'
652649
));
653-
$this->emitToken($this->token);
654650

655651
$this->stream->unget();
656652
$state = 'data';
@@ -725,13 +721,11 @@ public function parse() {
725721

726722
} elseif($char === false) {
727723
/* EOF
728-
Parse error. Emit the current tag token. Reconsume the EOF
729-
character in the data state. */
724+
Parse error. Reconsume the EOF character in the data state. */
730725
$this->emitToken(array(
731726
'type' => self::PARSEERROR,
732727
'data' => 'eof-in-attribute-name'
733728
));
734-
$this->emitToken($this->token);
735729

736730
$this->stream->unget();
737731
$state = 'data';
@@ -814,13 +808,11 @@ public function parse() {
814808

815809
} elseif($char === false) {
816810
/* EOF
817-
Parse error. Emit the current tag token. Reconsume the EOF
818-
character in the data state. */
811+
Parse error. Reconsume the EOF character in the data state. */
819812
$this->emitToken(array(
820813
'type' => self::PARSEERROR,
821814
'data' => 'expected-end-of-tag-but-got-eof'
822815
));
823-
$this->emitToken($this->token);
824816

825817
$this->stream->unget();
826818
$state = 'data';
@@ -892,13 +884,11 @@ public function parse() {
892884

893885
} elseif($char === false) {
894886
/* EOF
895-
Parse error. Emit the current tag token. Reconsume
896-
the character in the data state. */
887+
Parse error. Reconsume the EOF character in the data state. */
897888
$this->emitToken(array(
898889
'type' => self::PARSEERROR,
899890
'data' => 'expected-attribute-value-but-got-eof'
900891
));
901-
$this->emitToken($this->token);
902892
$this->stream->unget();
903893
$state = 'data';
904894

@@ -940,13 +930,11 @@ public function parse() {
940930

941931
} elseif($char === false) {
942932
/* EOF
943-
Parse error. Emit the current tag token. Reconsume the character
944-
in the data state. */
933+
Parse error. Reconsume the EOF character in the data state. */
945934
$this->emitToken(array(
946935
'type' => self::PARSEERROR,
947936
'data' => 'eof-in-attribute-value-double-quote'
948937
));
949-
$this->emitToken($this->token);
950938

951939
$this->stream->unget();
952940
$state = 'data';
@@ -980,13 +968,11 @@ public function parse() {
980968

981969
} elseif($char === false) {
982970
/* EOF
983-
Parse error. Emit the current tag token. Reconsume the character
984-
in the data state. */
971+
Parse error. Reconsume the EOF character in the data state. */
985972
$this->emitToken(array(
986973
'type' => self::PARSEERROR,
987974
'data' => 'eof-in-attribute-value-single-quote'
988975
));
989-
$this->emitToken($this->token);
990976

991977
$this->stream->unget();
992978
$state = 'data';
@@ -1029,13 +1015,11 @@ public function parse() {
10291015

10301016
} elseif ($char === false) {
10311017
/* EOF
1032-
Parse error. Emit the current tag token. Reconsume
1033-
the character in the data state. */
1018+
Parse error. Reconsume the EOF character in the data state. */
10341019
$this->emitToken(array(
10351020
'type' => self::PARSEERROR,
10361021
'data' => 'eof-in-attribute-value-no-quotes'
10371022
));
1038-
$this->emitToken($this->token);
10391023
$this->stream->unget();
10401024
$state = 'data';
10411025

@@ -1089,13 +1073,11 @@ public function parse() {
10891073

10901074
} elseif ($char === false) {
10911075
/* EOF
1092-
Parse error. Emit the current tag token. Reconsume the EOF
1093-
character in the data state. */
1076+
Parse error. Reconsume the EOF character in the data state. */
10941077
$this->emitToken(array(
10951078
'type' => self::PARSEERROR,
10961079
'data' => 'unexpected-EOF-after-attribute-value'
10971080
));
1098-
$this->emitToken($this->token);
10991081
$this->stream->unget();
11001082
$state = 'data';
11011083

@@ -1135,13 +1117,11 @@ public function parse() {
11351117

11361118
} elseif ($char === false) {
11371119
/* EOF
1138-
Parse error. Emit the current tag token. Reconsume the
1139-
EOF character in the data state. */
1120+
Parse error. Reconsume the EOF character in the data state. */
11401121
$this->emitToken(array(
11411122
'type' => self::PARSEERROR,
11421123
'data' => 'unexpected-eof-after-self-closing'
11431124
));
1144-
$this->emitToken($this->token);
11451125
$this->stream->unget();
11461126
$state = 'data';
11471127

@@ -1418,6 +1398,24 @@ public function parse() {
14181398
U+0020 SPACE
14191399
Switch to the before DOCTYPE name state. */
14201400
$state = 'before DOCTYPE name';
1401+
1402+
} elseif($char === false) {
1403+
/* EOF
1404+
Parse error. Create a new DOCTYPE token. Set its
1405+
force-quirks flag to on. Emit the token. Reconsume the
1406+
EOF character in the data state. */
1407+
$this->emitToken(array(
1408+
'type' => self::PARSEERROR,
1409+
'data' => 'need-space-after-doctype-but-got-eof'
1410+
));
1411+
$this->emitToken(array(
1412+
'name' => '',
1413+
'type' => self::DOCTYPE,
1414+
'force-quirks' => true,
1415+
'error' => true
1416+
));
1417+
$this->stream->unget();
1418+
$state = 'data';
14211419

14221420
} else {
14231421
/* Anything else

0 commit comments

Comments
 (0)