summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTechnosophos <[email protected]>2013-04-11 21:14:22 -0500
committerTechnosophos <[email protected]>2013-04-11 21:14:22 -0500
commit892335b82e3587fbb96ef4ef62bb1edd16ad636f (patch)
tree6738f7ae81c088d8c19f728604d11a492f9f1029
parentf0da96a373b912eb649954d7920a96c6284f9455 (diff)
endTag is done.
-rw-r--r--src/HTML5/Parser/Tokenizer.php2
-rw-r--r--test/HTML5/Parser/TokenizerTest.php26
2 files changed, 24 insertions, 4 deletions
diff --git a/src/HTML5/Parser/Tokenizer.php b/src/HTML5/Parser/Tokenizer.php
index 0eae949..81c4738 100644
--- a/src/HTML5/Parser/Tokenizer.php
+++ b/src/HTML5/Parser/Tokenizer.php
@@ -292,7 +292,7 @@ class Tokenizer {
$name = $this->scanner->charsUntil("\n\f \t>");
// Trash whitespace.
- $this->scanner->charsWhile("\n\f \t");
+ $this->scanner->whitespace();
if ($this->scanner->current() != '>') {
$this->parseError("Expected >, got '%s'", $this->scanner->current());
diff --git a/test/HTML5/Parser/TokenizerTest.php b/test/HTML5/Parser/TokenizerTest.php
index c31d74b..cae2adb 100644
--- a/test/HTML5/Parser/TokenizerTest.php
+++ b/test/HTML5/Parser/TokenizerTest.php
@@ -102,6 +102,8 @@ class TokenizerTest extends \HTML5\Tests\TestCase {
'</test>' => 'test',
'</test
>' => 'test',
+ '</thisIsTheTagThatDoesntEndItJustGoesOnAndOnMyFriend>' =>
+ 'thisIsTheTagThatDoesntEndItJustGoesOnAndOnMyFriend',
// See 8.2.4.10, which requires this and does not say error.
'</a<b>' => 'a<b',
);
@@ -114,12 +116,12 @@ class TokenizerTest extends \HTML5\Tests\TestCase {
}
+ // Recoverable failures
$fail = array(
'</a class="monkey">' => 'a',
'</a <b>' => 'a',
- '</ a>' => 'a',
- '</>' => '',
- '</ >' => '',
+ '</a <b <c>' => 'a',
+ '</a is the loneliest letter>' => 'a',
);
foreach ($fail as $test => $result) {
$events = $this->parse($test);
@@ -132,5 +134,23 @@ class TokenizerTest extends \HTML5\Tests\TestCase {
$this->assertEquals($result, $e1['data'][0], "Parse end tag " . $test);
$this->assertEquals(3, $events->depth());
}
+
+ // BogoComments
+ $comments = array(
+ '</>' => '</>',
+ '</ >' => '</ >',
+ '</ a>' => '</ a>',
+ );
+ foreach ($comments as $test => $result) {
+ $events = $this->parse($test);
+ // Should have triggered an error.
+ $e0 = $events->get(0);
+ $this->assertEquals('error', $e0['name'], "Parsing $test expects a leading error." . print_r($events, TRUE));
+ // Should have tried to parse anyway.
+ $e1 = $events->get(1);
+ $this->assertEquals('comment', $e1['name'], "Parsing $test expects comment." . print_r($events, TRUE));
+ $this->assertEquals($result, $e1['data'][0], "Parse end tag " . $test);
+ $this->assertEquals(3, $events->depth());
+ }
}
}