CDATA and JavaScript gets mangled when manipulating XHTML
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 45/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- html, javascript, php
- Domain
- web-dev
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.
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();
- Dominant language
- HTML
- Stars
- 1.8k
- Forks
- 123
- PR merge metrics
- No merged PRs in 30d
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
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.
More from Masterminds/html5-php
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
Masterminds/html5-php#280 ·
-
help-wanted
Difficulty 4/5 3-5 days Newbie friendliness 35/100
Masterminds/html5-php#252 · 1 comment · 1 reaction ·
-
Difficulty 3/5 1-2 days Newbie friendliness 35/100
Masterminds/html5-php#251 ·
-
Difficulty 3/5 1-2 days Newbie friendliness 35/100
Masterminds/html5-php#250 · 5 comments · 2 reactions ·
-
Difficulty 4/5 3-5 days Newbie friendliness 28/100
Masterminds/html5-php#246 · 1 comment ·
All issues in Masterminds/html5-php
Similar issues
-
Difficulty 1/5 Under an hour Newbie friendliness 72/100
betagouv/mon-entreprise#4699 ·
Maintainers usually reply within 3 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
Maintainers usually reply within 3 days
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
jaegertracing/jaeger-ui#4547 · 3 comments ·
Maintainers usually reply within 1 day
-
ai-driven-qa
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
linagora/twake-calendar-frontend#1467 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
auth0/universal-login#414 ·
Maintainers usually reply within 1 day