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

Commitd552aaf

Browse files
committed
Move the escape flag to inside Tokenizer::parse.
1 parent7c7bcb8 commitd552aaf

File tree

1 file changed

+15
-14
lines changed

1 file changed

+15
-14
lines changed

‎library/HTML5/Tokenizer.php

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,6 @@ class HTML5_Tokenizer {
4444
*/
4545
private$tree;
4646

47-
/**
48-
* Escape flag as specified by the HTML5 specification: "used to
49-
* control the behavior of the tokeniser. It is either true or
50-
* false, and initially must be set to the false state."
51-
*/
52-
private$escape =false;
53-
5447
/**
5548
* Current content model we are parsing as.
5649
*/
@@ -111,8 +104,16 @@ public function parseFragment($context = null) {
111104
* Performs the actual parsing of the document.
112105
*/
113106
publicfunctionparse() {
107+
// Current state
114108
$state ='data';
109+
// This is used to avoid having to have look-behind in the data state.
115110
$lastFourChars ='';
111+
/**
112+
* Escape flag as specified by the HTML5 specification: "used to
113+
* control the behavior of the tokeniser. It is either true or
114+
* false, and initially must be set to the false state."
115+
*/
116+
$escape =false;
116117
//echo "\n\n";
117118
while($state !==null) {
118119
/*
@@ -123,7 +124,7 @@ public function parse() {
123124
case self::CDATA: echo 'CDATA'; break;
124125
case self::PLAINTEXT: echo 'PLAINTEXT'; break;
125126
}
126-
if ($this->escape) echo " escape";
127+
if ($escape) echo " escape";
127128
echo "\n";
128129
*/
129130
switch($state) {
@@ -139,7 +140,7 @@ public function parse() {
139140

140141
// see below for meaning
141142
$amp_cond =
142-
!$this->escape &&
143+
!$escape &&
143144
(
144145
$this->content_model ===self::PCDATA ||
145146
$this->content_model ===self::RCDATA
@@ -151,7 +152,7 @@ public function parse() {
151152
$this->content_model ===self::RCDATA ||
152153
$this->content_model ===self::CDATA
153154
) &&
154-
!$this->escape
155+
!$escape
155156
);
156157

157158
if($char ==='&' &&$amp_cond) {
@@ -168,7 +169,7 @@ public function parse() {
168169
$this->content_model ===self::RCDATA ||
169170
$this->content_model ===self::CDATA
170171
) &&
171-
$this->escape ===false &&
172+
$escape ===false &&
172173
$lastFourChars ==='<!--'
173174
) {
174175
/*
@@ -179,7 +180,7 @@ public function parse() {
179180
last four characters in the input stream, including this one, are
180181
U+003C LESS-THAN SIGN, U+0021 EXCLAMATION MARK, U+002D HYPHEN-MINUS,
181182
and U+002D HYPHEN-MINUS ("<!--"), then set the escape flag to true. */
182-
$this->escape =true;
183+
$escape =true;
183184

184185
/* In any case, emit the input character as a character token. Stay
185186
in the data state. */
@@ -208,15 +209,15 @@ public function parse() {
208209
$this->content_model ===self::RCDATA ||
209210
$this->content_model ===self::CDATA
210211
) &&
211-
$this->escape ===true &&
212+
$escape ===true &&
212213
substr($lastFourChars,1) ==='-->'
213214
) {
214215
/* If the content model flag is set to either the RCDATA state or
215216
the CDATA state, and the escape flag is true, and the last three
216217
characters in the input stream including this one are U+002D
217218
HYPHEN-MINUS, U+002D HYPHEN-MINUS, U+003E GREATER-THAN SIGN ("-->"),
218219
set the escape flag to false. */
219-
$this->escape =false;
220+
$escape =false;
220221

221222
/* In any case, emit the input character as a character token.
222223
Stay in the data state. */

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp