Bug #81642 [NEW]: DOMChildNode::replaceWith() bug when replacing a node with itself.
| From: | jules dot bernable at gmail dot com | Date: | Fri, 19 Nov 2021 16:51:53 +0000 |
| Subject: | Bug #81642 [NEW]: DOMChildNode::replaceWith() bug when replacing a node with itself. | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-237876@lists.php.net to get a copy of this message | ||
From: jules dot bernable at gmail dot com
Operating system: debian unstable
PHP version: 8.1.0RC6
Package: DOM XML related
Bug Type: Bug
Bug description:DOMChildNode::replaceWith() bug when replacing a node with itself.
Description:
------------
When calling
DOMChildNode::replaceWith() on a given node,
If the node is also part of the argument list, PHP either throws a
DOMException or just hangs indefinitely.
The bug is present at least in versions 8.0.12 and 8.1.0RC6
Test script:
---------------
// example 1
$doc = new DOMDocument();
$doc->appendChild($target = $doc->createElement('test'));
$target->replaceWith($target); // PHP Fatal error: Uncaught
DOMException: Not Found Error
// example 2
$doc = new DOMDocument();
$doc->appendChild($target = $doc->createElement('test'));
$target->replaceWith($target, 'foo'); // program hangs indefinitely
Expected result:
----------------
Both examples should be handled correctly, like browsers do.
--
Edit bug report at https://bugs.php.net/bug.php?id=81642&edit=1
--
Fix committed: https://bugs.php.net/fix.php?id=81642&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=81642&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=81642&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=81642&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=81642&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=81642&r=support
Expected behavior: https://bugs.php.net/fix.php?id=81642&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=81642&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=81642&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=81642&r=globals
PHP version support discontinued: https://bugs.php.net/fix.php?id=81642&r=phptooold
Daylight Savings: https://bugs.php.net/fix.php?id=81642&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=81642&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=81642&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=81642&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=81642&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=81642&r=mysqlcfg