summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatt Farina <[email protected]>2014-02-07 23:07:32 -0500
committerMatt Farina <[email protected]>2014-02-07 23:07:32 -0500
commitd4b0222f622f3deb67d1c7366edc7f0a0aae9523 (patch)
treee58f17c8494a9a33d23b64bfdbd68c1765608eee
parent8785fc5775df52dd4a6b63677ebd08f8301ffdcc (diff)
#26: Updated the case handling for tags to allow for uppercase tags and normalizing tag names to lowercase (per 8.2.4.9) except for SVG foreign tags that are case sensitive.
-rw-r--r--src/HTML5/Parser/DOMTreeBuilder.php9
-rw-r--r--src/HTML5/Parser/Tokenizer.php4
-rw-r--r--test/HTML5/Html5Test.php2
-rw-r--r--test/HTML5/Parser/TokenizerTest.php8
4 files changed, 17 insertions, 6 deletions
diff --git a/src/HTML5/Parser/DOMTreeBuilder.php b/src/HTML5/Parser/DOMTreeBuilder.php
index 6dbd25e..13ae3bc 100644
--- a/src/HTML5/Parser/DOMTreeBuilder.php
+++ b/src/HTML5/Parser/DOMTreeBuilder.php
@@ -289,6 +289,11 @@ class DOMTreeBuilder implements EventHandler {
return;
}
+ // Special case handling for SVG.
+ if ($this->insertMode == static::IM_IN_SVG) {
+ $lname = Elements::normalizeSvgElement($lname);
+ }
+
// XXX: Not sure whether we need this anymore.
// if ($name != $lname) {
// return $this->quirksTreeResolver($lname);
@@ -301,8 +306,8 @@ class DOMTreeBuilder implements EventHandler {
}
//$this->current = $this->current->parentNode;
- if (!$this->autoclose($name)) {
- $this->parseError('Could not find closing tag for ' . $name);
+ if (!$this->autoclose($lname)) {
+ $this->parseError('Could not find closing tag for ' . $lname);
}
//switch ($this->insertMode) {
diff --git a/src/HTML5/Parser/Tokenizer.php b/src/HTML5/Parser/Tokenizer.php
index f81f069..04baa10 100644
--- a/src/HTML5/Parser/Tokenizer.php
+++ b/src/HTML5/Parser/Tokenizer.php
@@ -295,7 +295,7 @@ class Tokenizer {
return $this->bogusComment('</');
}
- $name = $this->scanner->charsUntil("\n\f \t>");
+ $name = strtolower($this->scanner->charsUntil("\n\f \t>"));
// Trash whitespace.
$this->scanner->whitespace();
@@ -831,7 +831,7 @@ class Tokenizer {
$buffer .= $this->scanner->charsUntil($first);
// Stop as soon as we hit the stopping condition.
- if ($this->sequenceMatches($sequence)) {
+ if ($this->sequenceMatches($sequence) || $this->sequenceMatches(strtoupper($sequence))) {
return $buffer;
}
$buffer .= $this->scanner->current();
diff --git a/test/HTML5/Html5Test.php b/test/HTML5/Html5Test.php
index 4e7c300..dcb51cd 100644
--- a/test/HTML5/Html5Test.php
+++ b/test/HTML5/Html5Test.php
@@ -134,7 +134,7 @@ class Html5Test extends TestCase {
</body>
</html>');
- $this->assertEmpty($dom->errors);
+ $this->assertEmpty($dom->errors, print_r($dom->errors, TRUE));
// Test a mixed case attribute.
$list = $dom->getElementsByTagName('svg');
diff --git a/test/HTML5/Parser/TokenizerTest.php b/test/HTML5/Parser/TokenizerTest.php
index edc427c..9f335b0 100644
--- a/test/HTML5/Parser/TokenizerTest.php
+++ b/test/HTML5/Parser/TokenizerTest.php
@@ -142,7 +142,7 @@ class TokenizerTest extends \HTML5\Tests\TestCase {
'</test
>' => 'test',
'</thisIsTheTagThatDoesntEndItJustGoesOnAndOnMyFriend>' =>
- 'thisIsTheTagThatDoesntEndItJustGoesOnAndOnMyFriend',
+ 'thisisthetagthatdoesntenditjustgoesonandonmyfriend',
// See 8.2.4.10, which requires this and does not say error.
'</a<b>' => 'a<b',
);
@@ -419,6 +419,12 @@ class TokenizerTest extends \HTML5\Tests\TestCase {
$this->assertEventEquals('text', $expects, $events->get(2));
}
+ // Testing case sensitivity
+ $events = $this->parse('<TITLE>a test</TITLE>');
+ $this->assertEventEquals('startTag', 'title', $events->get(0));
+ $this->assertEventEquals('text', 'a test', $events->get(1));
+ $this->assertEventEquals('endTag', 'title', $events->get(2));
+
}
public function testText() {