Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Whitespace in the end tag of RCDATA tags #75

Closed
zhaofengli opened this issue Feb 1, 2015 · 1 comment · Fixed by #76
Closed

Whitespace in the end tag of RCDATA tags #75

zhaofengli opened this issue Feb 1, 2015 · 1 comment · Fixed by #76

Comments

@zhaofengli
Copy link
Contributor

The parser is confused if you add whitespaces into </title>, like:

<title>Note the space after "title"</title >
<title>Another example<title
>

Both examples above are valid according to the W3 Validator.

This behaviour is caused by Tokenizer.php which assumes the end tag is always exactly </title>.

Test script

<?php
require_once __DIR__ . "/vendor/autoload.php";
$html = <<<EOF
<!doctype html>
<html>
<head>
    <title>This is valid, really.</title >
</head>
<body></body>
</html>
EOF;
$parser = new Masterminds\HTML5;
$dom = $parser->loadHTML( $html );
echo $parser->saveHTML( $dom );

Output

<!DOCTYPE html>
<html><head>
    <title>This is valid, really.&lt;/title &gt;
&lt;/head&gt;
&lt;body&gt;&lt;/body&gt;
&lt;/html&gt;</title></head></html>

Real-world examples

zhaofengli added a commit to zhaofengli/html5-php that referenced this issue Feb 2, 2015
Fixes Masterminds#75

Signed-off-by: Zhaofeng Li <hello@zhaofeng.li>
zhaofengli added a commit to zhaofengli/html5-php that referenced this issue Feb 2, 2015
Fixes Masterminds#75

Signed-off-by: Zhaofeng Li <hello@zhaofeng.li>
@technosophos
Copy link
Member

This looks good to me. Good catch. And thanks for including the tests.

@goetas goetas closed this as completed in #76 Feb 2, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants