Bug #76738 [Ver]: dom extension horrible broken in 7.3 master

From: Date: Tue, 14 Aug 2018 05:56:11 +0000
Subject: Bug #76738 [Ver]: dom extension horrible broken in 7.3 master
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-216774@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=76738&edit=1 ID: 76738 Updated by: requinix@php.net Reported by: spam2 at rhsoft dot net Summary: dom extension horrible broken in 7.3 master Status: Verified Type: Bug Package: DOM XML related PHP Version: 7.3Git-2018-08-13 (Git) Assigned To: ab Block user comment: N Private report: N New Comment: I've been digging into this for hours and I keep coming back to libxml being at fault. Or perhaps PHP using the wrong API? Specifically, htmlNodeDumpFormatOutput is being given the right node to dump, the outer buffer wrapper thing shows 4300+ bytes written, but the inner actual buffer shows only 300+ bytes written with the content starting at that </li>. I suspect the inner buffer either didn't expand properly, or there are two 4000-byte buffers in series and the one being examined is the latter. Unfortunately significant parts of the buffer system are private so I don't know what's going wrong. More confusing is that SimpleXML seems to be using the same function, and after fixing the markup to be XHTML, asXML() works fine. So I don't know. Previous Comments: ------------------------------------------------------------------------ [2018-08-13 21:48:22] cmb@php.net Thanks, Harald and Damian! Indeed, reverting commit ef9ed19[1] and its follow-up commit 36f05a8[2] seems to fix the regression. Unless there'll be a fix within the next 12 hours, I'll revert these commits from the PHP-7.3 branch before tagging php-7.3.0beta2. [1] <http://git.php.net/?p=php-src.git;a=commit;h=ef9ed19> [2] <http://git.php.net/?p=php-src.git;a=commit;h=36f05a8> ------------------------------------------------------------------------ [2018-08-13 18:19:35] spam2 at rhsoft dot net > Do any of them have to do with DOMDocument::saveHTML? surely and below i try to explain the background > Because the change for the bug I cited is the first time > PHP has used htmlNodeDumpFormatOutput() so in doubt we need just a option for the dom-extension to keep the old behavior unchanged, $dom->whatever = true/false, in the worst case introduced with PHP 7.3 so that we wrap it in a property_exists() or PHP_VERSION check in the full class linked below https://access.thelounge.net/harry/php-7.3-dom/global_rh_rte_helper.inc.txt every HTML content goes through the "magic methods" on_load() at read from database and on_save() before write back the WYSIWYG content which resluts any behavior change here which can't be avoided explicit breaks randomly code running in all previous php versions - in the example fxing a typo by the user would result in complete garbage of the whole cms-page tinyMCE other than XINHA insists in a block level element and by default wraps a <p></p> around the source which breaks perfect fine content like <strong>test</strong> when the WYSIWYG content is targetet for a template which already contains surrounding HTML hence we make sure everything is wrapped within <div class="tinymce-generated-root-block" style="margin: 0px; padding: 0px;"></div> at runtime and that this div-layer is removed before write back to the database ------------------------------------------------------------------------ [2018-08-13 17:37:45] requinix@php.net > how can it be a libxml problem when blah blah blah Because the change for the bug I cited is the first time PHP has used htmlNodeDumpFormatOutput(). If that's where the bug is then of course it's never been a problem before. > there are different dom related tests faling Do any of them have to do with DOMDocument::saveHTML? Because if so then they are relevant here. ------------------------------------------------------------------------ [2018-08-13 17:28:21] spam2 at rhsoft dot net how can it be a libxml problem when it's the identical environment (Fedora 28, gcc-8.2.1-1.fc28.x86_64, libxml2-devel-2.9.8-4.fc28.x86_64) where i take a tarball from https://git.php.net/?p=php-src.git put it into rpmbuild/SOURCES and fire up "rpmbuild -bb php.spec" which as part of the build process runs our test-suite and stops the build if it fails? it fails not only that one example, there are different dom related tests faling hwich are running for years on several PHP and Fedora versions and it took me enough time to isolate that one which is only an example of a underlying issue ------------------------------------------------------------------------ [2018-08-13 17:17:22] requinix@php.net Likely introduced with bug #76285 https://github.com/php/php-src/commit/ef9ed19ec7f141311feea1d42467f5773cfc09bc Not sure if PHP bug or libxml bug. I kinda suspect the latter since nothing seems obviously wrong on the PHP side. It's clearly an issue related to buffering; rather than try to explain the behavior, take the repro script and 1. Remove the $test_string= line 2. Add $test_string=<<<FOO (the content from the 7.2.9 output) FOO; 3. Run to get the 7.3.0 output 4. Duplicate one or two of the MUSIK <li>s 5. Run again to get output that's cutoff differently The cutoff happens at buffered points, like |</li> or li|> or |li> and never l|i>. The first one happens at 4060 bytes of output, which is close to both 4000 (libxml's BASE_BUFFER_SIZE) and 4KB. ------------------------------------------------------------------------ The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at https://bugs.php.net/bug.php?id=76738 -- Edit this bug report at https://bugs.php.net/bug.php?id=76738&edit=1

« previous php.bugs (#216774) next »