Bug #71993 [Opn->Nab]: DOMDocument::loadHTML ignores anything after a null byte

From: Date: Wed, 13 Apr 2016 07:29:17 +0000
Subject: Bug #71993 [Opn->Nab]: DOMDocument::loadHTML ignores anything after a null byte
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-200515@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=71993&edit=1

 ID:                 71993
 Updated by:         ab@php.net
 Reported by:        raul at raulr dot net
 Summary:            DOMDocument::loadHTML ignores anything after a null
                     byte
-Status:             Open
+Status:             Not a bug
 Type:               Bug
 Package:            DOM XML related
 Operating System:   Linux
 PHP Version:        7.0.5
 Block user comment: N
 Private report:     N

 New Comment:

Thanks for the report. The input comes as a binary safe string in PHP, then we reevaluate it using
xmlStrlen(). But even without it, libxml2 will retain same behavior just silently stopping. Thus it
is not a bug in PHP, this should be reevaluated once libxml2 has a better HTML5support. Please see
also this couple of links

https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=574104
https://mail.gnome.org/archives/xml/2008-August/msg00008.html

Thanks.


Previous Comments:
------------------------------------------------------------------------
[2016-04-08 19:18:35] raul at raulr dot net

Description:
------------
DOMDocument::loadHTML() stops processing the source string after a null byte (U+0000) without
issuing any exception or warning.

I have tested that this happens in PHP versions 5.5.34, 5.6.20 and 7.0.5.

Test script:
---------------
<?php

$html = <<<EOD
<!DOCTYPE html>
<html>
<div>Pre NULL byte</div>
\0
<div>Post NULL byte</div>
</html>
EOD;

$dom = new \DOMDocument('1.0');
$dom->validateOnParse = true;
$dom->loadHTML($html);
echo $dom->saveHTML();

Expected result:
----------------
<!DOCTYPE html>
<html><body><div>Pre NULL byte</div>

<div>Post NULL byte</div>
</body></html>

Actual result:
--------------
<!DOCTYPE html>
<html><body><div>Pre NULL byte</div></body></html>


------------------------------------------------------------------------



--
Edit this bug report at https://bugs.php.net/bug.php?id=71993&edit=1


Thread (2 messages)

« previous php.bugs (#200515) next »