Bug #72288 [NEW]: Lines longer than 1000 characters break DOMDocument::loadHTML()

From: Date: Mon, 30 May 2016 09:13:09 +0000
Subject: Bug #72288 [NEW]: Lines longer than 1000 characters break DOMDocument::loadHTML()
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-201334@lists.php.net to get a copy of this message
From: maciej at klepaczewski dot com Operating system: Windows, Linux PHP version: 5.6.22 Package: DOM XML related Bug Type: Bug Bug description:Lines longer than 1000 characters break DOMDocument::loadHTML() Description: ------------ When a single line contains more than 1000 characters (might depend on EOL format) DOMDocument::loadHTML() errs with message similar to: ===== Warning: DOMDocument::loadHTML(): Unexpected end tag : head in Entity, line: 7 in test.php on line 4 Warning: DOMDocument::loadHTML(): htmlParseStartTag: misplaced <body> tag in Entity, line: 8 in test.php on line 4 ===== Test script: --------------- <?php error_reporting(E_ALL); $html = <<<HTML <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="da" lang="da"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> <title>Test</title> <!--placeholder--> </head> <body> </body> </html> HTML; echo "==== < 1000 spaces in head===\n"; $x = new DOMDocument(); $x->loadHTML(str_replace('<!--placeholder-->', str_repeat(' ', 995), $html)); echo "==== 1000 spaces in head===\n"; $y = new DOMDocument(); $y->loadHTML(str_replace('<!--placeholder-->', str_repeat(' ', 1000), $html)); Expected result: ---------------- ==== < 1000 spaces in head=== ==== 1000 spaces in head=== Actual result: -------------- ==== < 1000 spaces in head=== ==== 1000 spaces in head=== Warning: DOMDocument::loadHTML(): Unexpected end tag : head in Entity, line: 7 in test.php on line 20 Warning: DOMDocument::loadHTML(): htmlParseStartTag: misplaced <body> tag in Entity, line: 8 in test.php on line 20 -- Edit bug report at https://bugs.php.net/bug.php?id=72288&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=72288&r=trysnapshot54 Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=72288&r=trysnapshot55 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=72288&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=72288&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=72288&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=72288&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=72288&r=needscript Try newer version: https://bugs.php.net/fix.php?id=72288&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=72288&r=support Expected behavior: https://bugs.php.net/fix.php?id=72288&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=72288&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=72288&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=72288&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=72288&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=72288&r=dst IIS Stability: https://bugs.php.net/fix.php?id=72288&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=72288&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=72288&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=72288&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=72288&r=mysqlcfg

« previous php.bugs (#201334) next »