Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commita1afbbe

Browse files
committed
Merge more complex if statements in the data state to make it clearer we can grab even more data, but not actually grabbing more till I understand what Edward is doing. :D
1 parent4e3cd44 commita1afbbe

File tree

1 file changed

+28
-15
lines changed

1 file changed

+28
-15
lines changed

‎library/HTML5/Tokenizer.php

Lines changed: 28 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -153,25 +153,32 @@ public function parse() {
153153
the "anything else" entry below. */
154154
$state ='characterReferenceData';
155155

156-
}elseif($char ==='-') {
157-
/* If the content model flag is set to either the RCDATA state or
156+
}elseif(
157+
$char ==='-' &&
158+
(
159+
$this->content_model ===self::RCDATA ||
160+
$this->content_model ===self::CDATA
161+
) &&
162+
$this->escape ===false &&
163+
$lastFourChars ==='<!--'
164+
) {
165+
/*
166+
U+002D HYPHEN-MINUS (-)
167+
If the content model flag is set to either the RCDATA state or
158168
the CDATA state, and the escape flag is false, and there are at
159169
least three characters before this one in the input stream, and the
160170
last four characters in the input stream, including this one, are
161171
U+003C LESS-THAN SIGN, U+0021 EXCLAMATION MARK, U+002D HYPHEN-MINUS,
162172
and U+002D HYPHEN-MINUS ("<!--"), then set the escape flag to true. */
163-
if(($this->content_model ===self::RCDATA ||$this->content_model ===
164-
self::CDATA) &&$this->escape ===false &&
165-
$lastFourChars ==='<!--') {
166-
$this->escape =true;
167-
}
173+
$this->escape =true;
168174

169175
/* In any case, emit the input character as a character token. Stay
170176
in the data state. */
171177
$this->emitToken(array(
172178
'type' =>self::CHARACTER,
173-
'data' =>$char
179+
'data' =>'-'
174180
));
181+
// We do the "any case" part as part of "anything else".
175182

176183
/* U+003C LESS-THAN SIGN (<) */
177184
}elseif($char ==='<' &&$lt_cond) {
@@ -186,24 +193,29 @@ public function parse() {
186193
$state ='tagOpen';
187194

188195
/* U+003E GREATER-THAN SIGN (>) */
189-
}elseif($char ==='>') {
196+
}elseif(
197+
$char ==='>' &&
198+
(
199+
$this->content_model ===self::RCDATA ||
200+
$this->content_model ===self::CDATA
201+
) &&
202+
$this->escape ===true &&
203+
substr($lastFourChars,1) ==='-->'
204+
) {
190205
/* If the content model flag is set to either the RCDATA state or
191206
the CDATA state, and the escape flag is true, and the last three
192207
characters in the input stream including this one are U+002D
193208
HYPHEN-MINUS, U+002D HYPHEN-MINUS, U+003E GREATER-THAN SIGN ("-->"),
194209
set the escape flag to false. */
195-
if(($this->content_model ===self::RCDATA ||
196-
$this->content_model ===self::CDATA) &&$this->escape ===true &&
197-
substr($lastFourChars,1) ==='-->') {
198-
$this->escape =false;
199-
}
210+
$this->escape =false;
200211

201212
/* In any case, emit the input character as a character token.
202213
Stay in the data state. */
203214
$this->emitToken(array(
204215
'type' =>self::CHARACTER,
205-
'data' =>$char
216+
'data' =>'>'
206217
));
218+
// We do the "any case" part as part of "anything else".
207219

208220
}elseif($char ===false) {
209221
/* EOF
@@ -223,6 +235,7 @@ public function parse() {
223235
// XSKETCHY: introduced three more fails (at least)
224236
if ($char !=='' &&$char !=="\n" &&$char !=="\r" &&
225237
$char !=="\t" &&$char !=="\x0c") {
238+
// XXX: We should only have - and > here when they need to be.
226239
$mask ='->' .self::WHITESPACE;
227240
if ($amp_cond)$mask .='&';
228241
if ($lt_cond)$mask .='<';

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp