diff options
author | Asmir Mustafic <[email protected]> | 2015-02-02 18:03:22 +0100 |
---|---|---|
committer | Asmir Mustafic <[email protected]> | 2015-02-02 18:03:22 +0100 |
commit | 9d8898a3fc8e2d4c1e57c2cc5df6e244bed6df63 (patch) | |
tree | 41e79117a91d4a64c926b2adf6137f1739f99638 | |
parent | 700717e32d20813053f37244ee0b5bb0d0b0180e (diff) | |
parent | 7c1c7dfab1b258d0b93975e7abf20de191974ad7 (diff) |
Merge pull request #76 from zhaofengli/i75
Allow whitespaces in RCDATA end tags
-rw-r--r-- | src/HTML5/Parser/Tokenizer.php | 9 | ||||
-rw-r--r-- | test/HTML5/Parser/TokenizerTest.php | 6 |
2 files changed, 14 insertions, 1 deletions
diff --git a/src/HTML5/Parser/Tokenizer.php b/src/HTML5/Parser/Tokenizer.php index 958ade8..e00b9a2 100644 --- a/src/HTML5/Parser/Tokenizer.php +++ b/src/HTML5/Parser/Tokenizer.php @@ -200,7 +200,7 @@ class Tokenizer if (is_null($this->untilTag)) { return $this->text(); } - $sequence = '</' . $this->untilTag . '>'; + $sequence = '</' . $this->untilTag; $txt = ''; $tok = $this->scanner->current(); @@ -214,6 +214,13 @@ class Tokenizer $tok = $this->scanner->next(); } } + $len = strlen($sequence); + $this->scanner->consume($len); + $len += strlen($this->scanner->whitespace()); + if ($this->scanner->current() !== '>') { + $this->parseError("Unclosed RCDATA end tag"); + } + $this->scanner->unconsume($len); $this->events->text($txt); $this->setTextMode(0); return $this->endTag(); diff --git a/test/HTML5/Parser/TokenizerTest.php b/test/HTML5/Parser/TokenizerTest.php index 8ff4d5c..3d834fd 100644 --- a/test/HTML5/Parser/TokenizerTest.php +++ b/test/HTML5/Parser/TokenizerTest.php @@ -884,6 +884,12 @@ class TokenizerTest extends \Masterminds\HTML5\Tests\TestCase $this->assertEventEquals('startTag', 'title', $events->get(0)); $this->assertEventEquals('text', 'a test', $events->get(1)); $this->assertEventEquals('endTag', 'title', $events->get(2)); + + // Testing end tags with whitespaces + $events = $this->parse('<title>Whitespaces are tasty</title >'); + $this->assertEventEquals('startTag', 'title', $events->get(0)); + $this->assertEventEquals('text', 'Whitespaces are tasty', $events->get(1)); + $this->assertEventEquals('endTag', 'title', $events->get(2)); } public function testRcdata() |