diff options
Diffstat (limited to 'test/HTML5/Parser/DOMTreeBuilderTest.php')
-rw-r--r-- | test/HTML5/Parser/DOMTreeBuilderTest.php | 74 |
1 files changed, 74 insertions, 0 deletions
diff --git a/test/HTML5/Parser/DOMTreeBuilderTest.php b/test/HTML5/Parser/DOMTreeBuilderTest.php index 3e1a58f..a441af8 100644 --- a/test/HTML5/Parser/DOMTreeBuilderTest.php +++ b/test/HTML5/Parser/DOMTreeBuilderTest.php @@ -58,6 +58,80 @@ class DOMTreeBuilderTest extends \Masterminds\HTML5\Tests\TestCase $this->assertEquals('http://www.w3.org/1999/xhtml', $doc->documentElement->namespaceURI); } + public function testBareAmpersand() + { + $html = "<!doctype html> + <html> + <body> + <img src='a&b' /> + <img src='a&=' /> + <img src='a&=c' /> + <img src='a&=9' /> + </body> + </html>"; + $doc = $this->parse($html); + + $this->assertEmpty($this->errors); + $this->assertXmlStringEqualsXmlString(' + <!DOCTYPE html> + <html xmlns="http://www.w3.org/1999/xhtml"><body> + <img src="a&b"/> + <img src="a&="/> + <img src="a&=c"/> + <img src="a&=9"/> + </body> + </html>', $doc->saveXML()); + } + + public function testBareAmpersandNotAllowedInAttributes() + { + $html = "<!doctype html> + <html> + <body> + <img src='a&' /> + <img src='a&+' /> + </body> + </html>"; + $doc = $this->parse($html); + + $this->assertCount(2, $this->errors); + $this->assertXmlStringEqualsXmlString(' + <!DOCTYPE html> + <html xmlns="http://www.w3.org/1999/xhtml"><body> + <img src="a&"/> + <img src="a&+"/> + </body> + </html>', $doc->saveXML()); + } + public function testBareAmpersandNotAllowedInBody() + { + $html = "<!doctype html> + <html> + <body> + a&b + a&= + a&=c + a&=9 + a&+ + a& -- valid + </body> + </html>"; + $doc = $this->parse($html); + + $this->assertCount(5, $this->errors); + $this->assertXmlStringEqualsXmlString(' + <!DOCTYPE html> + <html xmlns="http://www.w3.org/1999/xhtml"><body> + a&b + a&= + a&=c + a&=9 + a&+ + a& -- valid + </body> + </html>', $doc->saveXML()); + } + public function testStrangeCapitalization() { $html = "<!doctype html> |