After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 784517 - php DOMDocument loadHTML parses html tags inside cdata
php DOMDocument loadHTML parses html tags inside cdata
Status: RESOLVED INVALID
Product: libxml++
Classification: Bindings
Component: DOM Parser
2.9.x
Other Windows
: Normal normal
: ---
Assigned To: Christophe de Vienne
Christophe de Vienne
Depends on:
Blocks:
 
 
Reported: 2017-07-04 15:18 UTC by Dinar
Modified: 2017-07-05 06:49 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Dinar 2017-07-04 15:18:34 UTC
test script:

<?php
$test_content='
<script>
//<![CDATA[
a=\'123\';
b=\'</script>\';
c=\'456\';
//]]>
</script>
';
$d=new DOMDocument();
$d->loadHTML($test_content);
echo $d->saveHTML();

---end of the test script---

its output:

PHP Warning:  DOMDocument::loadHTML(): Unexpected end tag : script in Entity, line: 8 in C:\xampp\htdocs\test\dom_cdata.php on line 13

Warning: DOMDocument::loadHTML(): Unexpected end tag : script in Entity, line: 8 in C:\xampp\htdocs\test\dom_cdata.php on line 13
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<html><head><script>
//<![CDATA[
a='123';
b='</script></head><body><p>';
c='456';
//]]&gt;
</p></body></html>

---end of the output---

-- so, you can see that cdata which was used to escape html tags inside strings inside script tags failed to perform that task while it was feed to PHP's DOMDocument's loadHTML , which is made with libxml. [and you can see here that] "c='456'; //]]> " - content of script element is going to be outputted to user.
Comment 1 Murray Cumming 2017-07-05 06:15:52 UTC
> failed to perform that task while it was feed to PHP's DOMDocument's loadHTML , which is made with libxml

You have reported this to the libxml++ project (C++ bindings for libxml). Please report this to the PHP project.
Comment 2 Dinar 2017-07-05 06:39:23 UTC
i have found that it is already reported: https://bugs.php.net/bug.php?id=71452 .
Comment 3 Dinar 2017-07-05 06:41:51 UTC
i see now that it is not with cdata, so i will report another bug.
Comment 4 Dinar 2017-07-05 06:49:25 UTC
https://bugs.php.net/bug.php?id=74858