Bug #80680 [NEW]: DOMNode::getNodePath() returns XPath that is invalid for DOMXPath::query()

From: Date: Thu, 28 Jan 2021 11:30:39 +0000
Subject: Bug #80680 [NEW]: DOMNode::getNodePath() returns XPath that is invalid for DOMXPath::query()
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-231811@lists.php.net to get a copy of this message
From: andrey at email dot dp dot ua Operating system: Debian Linux PHP version: Irrelevant Package: DOM XML related Bug Type: Bug Bug description:DOMNode::getNodePath() returns XPath that is invalid for DOMXPath::query() Description: ------------ DOMNode::getNodePath() for DOMDocumentType node returns XPath value that is not valid for DOMXPath::query() Test script: --------------- <?php $html = <<<EOF <?xml version="1.0" encoding="UTF-8"?> <!doctype html> <html></html> EOF; $dom = new \DOMDocument(); $dom->loadHTML($html); $xpath = new \DOMXPath($dom); foreach ($dom->childNodes as $cur_child_node) { if (!$cur_child_node instanceof DOMDocumentType) { continue; } $DOMDocumentType_xpath = $cur_child_node->getNodePath(); echo "\$DOMDocumentType_xpath = ".$DOMDocumentType_xpath."\n"; $nodelist = $xpath->query($DOMDocumentType_xpath); var_dump($nodelist); } Expected result: ---------------- $DOMDocumentType_xpath = /? object(DOMNodeList)#7 (1) { ["length"]=> int(1) } Actual result: -------------- $DOMDocumentType_xpath = /? PHP Warning: DOMXPath::query(): Invalid expression in test_xpath.php on line 30 bool(false) -- Edit bug report at https://bugs.php.net/bug.php?id=80680&edit=1 -- Fix committed: https://bugs.php.net/fix.php?id=80680&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=80680&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=80680&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=80680&r=needscript Try newer version: https://bugs.php.net/fix.php?id=80680&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=80680&r=support Expected behavior: https://bugs.php.net/fix.php?id=80680&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=80680&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=80680&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=80680&r=globals PHP version support discontinued: https://bugs.php.net/fix.php?id=80680&r=phptooold Daylight Savings: https://bugs.php.net/fix.php?id=80680&r=dst IIS Stability: https://bugs.php.net/fix.php?id=80680&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=80680&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=80680&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=80680&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=80680&r=mysqlcfg

« previous php.bugs (#231811) next »