Bug #74628 [Opn->Sus]: DOM auto remove HTML closing tag in <script> tag when save
| From: | cmb@php.net | Date: | Mon, 22 May 2017 16:37:34 +0000 |
| Subject: | Bug #74628 [Opn->Sus]: DOM auto remove HTML closing tag in <script> tag when save | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-209229@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=74628&edit=1
ID: 74628
Updated by: cmb@php.net
Reported by: tidus2102 at gmail dot com
Summary: DOM auto remove HTML closing tag in <script> tag
when save
-Status: Open
+Status: Suspended
Type: Bug
Package: DOM XML related
Operating System: OSX El Capitan
PHP Version: 7.1.5
Block user comment: N
Private report: N
New Comment:
Unfortunately, libxml isn't really HTML5 compatible yet, and there
isn't much we can do about that. You have to stick to conforming
HTML 4.01, and write <\/h1>, see <https://3v4l.org/ldGmr>.
Previous Comments:
------------------------------------------------------------------------
[2017-05-22 04:27:10] tidus2102 at gmail dot com
Description:
------------
http://stackoverflow.com/questions/4029341/dom-parser-that-allows-html5-style-in-script-tag
DOM auto remove HTML closing tag in <script> tag when save. Please check test script below.
Test script:
---------------
$html = <<<HTML
<script>
console.log('<h1>aaa</h1>');
</script>
HTML;
$dom = new DOMDocument();
libxml_use_internal_errors(true);
$dom->loadHTML(mb_convert_encoding($html, 'HTML-ENTITIES', "UTF-8"),
LIBXML_HTML_NODEFDTD | LIBXML_HTML_NOIMPLIED);
echo $dom->saveHTML();
die;
Expected result:
----------------
All content in <script> tag need to be exactly the same as original HTML code.
<script>
console.log('<h1>aaa</h1>');
</script>
Actual result:
--------------
<script>
console.log('<h1>aaa');
</script>
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=74628&edit=1