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

Commitd49a53f

Browse files
author
Edward Z. Yang ext:(%22)
committed
Fix error in lastFourChars impl for early versions of PHP.
1 parent9c3d808 commitd49a53f

File tree

3 files changed

+24
-6
lines changed

3 files changed

+24
-6
lines changed

‎library/HTML5/Tokenizer.php

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,17 @@ public function parse() {
105105
$lastFourChars ='';
106106
//echo "\n\n";
107107
while($state !==null) {
108-
//echo $state . "\n";
108+
/*
109+
echo $state . ' ';
110+
switch ($this->content_model) {
111+
case self::PCDATA: echo 'PCDATA'; break;
112+
case self::RCDATA: echo 'RCDATA'; break;
113+
case self::CDATA: echo 'CDATA'; break;
114+
case self::PLAINTEXT: echo 'PLAINTEXT'; break;
115+
}
116+
if ($this->escape) echo " escape";
117+
echo "\n";
118+
*/
109119
switch($state) {
110120
case'data':
111121

@@ -114,7 +124,8 @@ public function parse() {
114124

115125
/* Consume the next input character */
116126
$char =$this->stream->char();
117-
$lastFourChars =substr($lastFourChars .$char, -4);
127+
$lastFourChars .=$char;
128+
if (strlen($lastFourChars) >4)$lastFourChars =substr($lastFourChars, -4);
118129

119130
// see below for meaning
120131
$amp_cond =
@@ -218,7 +229,7 @@ public function parse() {
218229
'data' =>$char .$chars
219230
));
220231

221-
$lastFourChars=substr($lastFourChars .$chars, -4);
232+
$lastFourChars.=$chars;
222233

223234
$state ='data';
224235
}

‎library/HTML5/TreeConstructer.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1682,7 +1682,6 @@ public function emitToken($token, $mode = null) {
16821682

16831683
/* If node has the same tag name as the end tag token,
16841684
then: */
1685-
if ($token['name'] ==='label')var_dump($node->tagName);
16861685
if($token['name'] ===$node->tagName) {
16871686
/* Generate implied end tags. */
16881687
$this->generateImpliedEndTags();

‎tests/HTML5/TokenizerTest.php

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,19 @@ public function invoke($test) {
3131
);
3232
if ($expect !=$result) {
3333
echo"Input:";str_dump($test->input);
34-
echo"Expected:";var_dump($expect);
35-
echo"Actual:";var_dump($result);
34+
echo"\nExpected:\n";echo$this->tokenDump($expect);
35+
echo"\nActual:\n";echo$this->tokenDump($result);
36+
echo"\n";
3637
}
3738
}
3839
}
40+
privatefunctiontokenDump($tokens) {
41+
$ret ='';
42+
foreach ($tokensas$i =>$token) {
43+
$ret .= ($i+1).".{$token[0]}:{$token[1]}\n";
44+
}
45+
return$ret;
46+
}
3947
publicfunctiontokenize($test,$flag) {
4048
$flag =constant("HTML5_Tokenizer::$flag");
4149
if (!isset($test->lastStartTag))$test->lastStartTag =null;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp