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
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: morozov at tut dot by
New email:
PHP Version: OS:

 

 [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-2020 The PHP Group
All rights reserved.
Last updated: Sat Jul 04 19:01:16 2020 UTC