Masterminds / Masterminds/html5-php
CDATA and JavaScript gets mangled when manipulating XHTML
Nobody has claimed this yet.
- Dominant language
- HTML
- Stars
- 1.8k
- Forks
- 122
- PR merge metrics
- No merged PRs in 30d
Description
When loading a XHTML document with JavaScript into html5-php I expect the <script>//<![CDATA[ conversion to behave like it does in plain old \DOMDocument. Instead they get turned into htmlentities, breaking the JavaScript on our target platforms (ebook readers).
Expected:
<script>
//<![CDATA[
for ( var i = 0; i < 10; i++ ) {
console.log(i);
}
//]]>
</script>
Actual:
<script>
//<![CDATA[
for ( var i = 0; i < 10; i++ ) {
console.log(i);
}
//]]>
</script>
<becomes<,>becomes>, ...
Test case:
$body = '<?xml version="1.0" encoding="UTF-8" ?>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<title>Test</title>
</head>
<body>
<p>Hi There!</p>
<script>
//<![CDATA[
for ( var i = 0; i < 10; i++ ) {
console.log(i);
}
//]]>
</script>
</body>
</html>';
$d1 = new \DOMDocument();
$d1->loadXml( $body );
echo $d1->saveXML();
$mm = new \Masterminds\HTML5();
$d2 = $mm->loadHTML( $body );
echo $d2->saveXML();
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by running the supplied PHP test case and compare DOMDocument with Masterminds\HTML5 loadHTML followed by saveXML. Trace the parser and serializer path responsible for script content; done means CDATA markers and comparison operators remain literal instead of becoming HTML entities.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- html, javascript, php
- Domain
- web-dev
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100