Bug #78129 [Opn]: DOMDocument removes whitespace between nodes
| From: | nospam at unclassified dot de | Date: | Sun, 07 Jun 2020 15:33:25 +0000 |
| Subject: | Bug #78129 [Opn]: DOMDocument removes whitespace between nodes | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-227349@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=78129&edit=1
ID: 78129
User updated by: nospam at unclassified dot de
Reported by: nospam at unclassified dot de
Summary: DOMDocument removes whitespace between nodes
Status: Open
Type: Bug
Package: *General Issues
Operating System: Linux
PHP Version: 7.3.6
Block user comment: N
Private report: N
New Comment:
Is this issue tracker still in use and is anybody here? It feels a little lonely in here.
Previous Comments:
------------------------------------------------------------------------
[2019-11-02 19:20:57] nospam at unclassified dot de
Can somebody please have a quick look at this? To me this looks like a simple fix, just edit that
one line that sets the option for the Linux build.
------------------------------------------------------------------------
[2019-06-08 14:41:14] nospam at unclassified dot de
It seems Linux always adds the LIBXML_NOBLANKS option whereas Windows does not. I can get the same
result on Windows as on Linux when I use this code:
$dom->loadHTML($html, LIBXML_NOBLANKS);
But there is not option that inverts that option. To me it looks like the Linux build of PHP has the
bug that the LIBXML_NOBLANKS option is always added while it should not. I couldn't find
information about that option because the libxml documentation has no description of this option.
It's just empty.
------------------------------------------------------------------------
[2019-06-08 14:31:05] nospam at unclassified dot de
Description:
------------
The DOMDocument removes whitespace between HTML elements when loading and saving HTML content. This
leads to wrong display of content. The bug only affects Linux, it works correctly in Windows (same
version).
Test script:
---------------
<?php
$html = '<html>
<body>
<p>
Text
</p>
<lang>Logged in as</lang>
<strong>user</strong>
<script src="jquery-3.4.1.min.js"></script>
<script src="site.js"></script>
</body>
</html>';
libxml_use_internal_errors(true);
$dom = new DOMDocument();
$dom->loadHTML($html);
header('Content-Type: text/plain');
echo $dom->saveHTML();
Expected result:
----------------
This is the output on Windows:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<html>
<body>
<p>
Text
</p>
<lang>Logged in as</lang>
<strong>user</strong>
<script src="jquery-3.4.1.min.js"></script>
<script src="site.js"></script>
</body>
</html>
Actual result:
--------------
This is the output on Linux:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<html><body>
<p>
Text
</p>
<lang>Logged in as</lang><strong>user</strong>
<script src="jquery-3.4.1.min.js"></script><script
src="site.js"></script></body></html>
There is no space between "Logged in as" and "user". The <lang> element is
a custom element that my PHP script will resolve into plain HTML.
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=78129&edit=1