php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #77651 DOMDocument preserves insignificant whitespace text nodes
Submitted: 2019-02-22 00:26 UTC Modified: -
Votes:1
Avg. Score:4.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: morozov at tut dot by Assigned:
Status: Open Package: DOM XML related
PHP Version: 7.3.2 OS: Windows
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2019-02-22 00:26 UTC] morozov at tut dot by
Description:
------------
DOMDocument::loadHTML() produces different results on Windows and Linux. Whitespace text nodes are ignored between non-inline elements on Linux but not on Windows.

The different behaviors are observed on the same PHP version (7.3.2) and very close libxml versions (2.9.3 on Linux and 2.9.8 on Windows).

Test script:
---------------
$doc = new DOMDocument();
$doc->loadHTML(
    <<<HTML
<html>
    <body>
        <map>
           <area />
        </map>
        <div>
           <span />
        </div>
    </body>
</html>
HTML
);

var_dump(
    $doc->getElementsByTagName('map')
        ->item(0)
        ->childNodes
        ->length
);

var_dump(
    $doc->getElementsByTagName('div')
        ->item(0)
        ->childNodes
        ->length
);

Expected result:
----------------
int(1)
int(3)

Actual result:
--------------
int(3)
int(3)

Patches

Add a Patch

Pull Requests

Add a Pull Request

 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Thu Dec 05 20:01:24 2019 UTC