-
Notifications
You must be signed in to change notification settings - Fork 115
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
CDATA and JavaScript gets mangled when manipulating XHTML #139
Comments
I would like to submit a PR but I need clarification on: /**
* A unit of parsed character data.
*
* Entities in this text are *already decoded*.
*/
public function text($cdata); What does Entities in this text are *already decoded* mean? If it means that // fprintf(STDOUT, "Appending text %s.", $data);
$node = $this->doc->createTextNode($data);
$this->current->appendChild($node); To:
Solves this issue.
|
The thing is that "script" is a raw text tag, so Tokenizer::rawText() looks directly for </script> instead of looking for a possible cdata sequence. When serializing back the dom, are you using this lib or the domdocument::save xml method? |
I am using this lib:
My question, worded another way, is what is If this is the case then my proposed fix is no good. |
Ok, duh. No I am not. My mistake. When changing to:
I get:
Maybe this is #nobug? Thank you for your patience. |
Doing $html = '
<!DOCTYPE html>
<html>
<head>
<script>ababc</script>
<script>ab < abc</script>
<script>
// <![CDATA[
foo <
// ]]>
bar
</script>
</head>
</html>';
$html5 = new HTML5();
$doc = $html5->loadHTML($html);
var_dump($html5->saveHTML($doc)); I get:
|
Back from vacation so excuse the all over the place tangent. Elsewhere in our code, we have often used For this specific bug we need to save back as valid XML. We expect similar results to I just tried the proposed fix and, for this specific bug, and it doesn' work for us because The issue remains. We need
Preserved in XML saves like |
|
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:
Actual:
Test case:
The text was updated successfully, but these errors were encountered: