Bug #71993 [NEW]: DOMDocument::loadHTML ignores anything after a null byte

From: Date: Fri, 08 Apr 2016 19:18:43 +0000
Subject: Bug #71993 [NEW]: DOMDocument::loadHTML ignores anything after a null byte
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-200442@lists.php.net to get a copy of this message
From: raul at raulr dot net Operating system: Linux PHP version: 7.0.5 Package: DOM XML related Bug Type: Bug Bug description:DOMDocument::loadHTML ignores anything after a null byte 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 bug report at https://bugs.php.net/bug.php?id=71993&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=71993&r=trysnapshot54 Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=71993&r=trysnapshot55 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=71993&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=71993&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=71993&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=71993&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=71993&r=needscript Try newer version: https://bugs.php.net/fix.php?id=71993&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=71993&r=support Expected behavior: https://bugs.php.net/fix.php?id=71993&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=71993&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=71993&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=71993&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=71993&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=71993&r=dst IIS Stability: https://bugs.php.net/fix.php?id=71993&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=71993&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=71993&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=71993&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=71993&r=mysqlcfg

« previous php.bugs (#200442) next »