Bug #78299 [NEW]: Custom entities in attributes are lost while importing

From: Date: Tue, 16 Jul 2019 09:02:10 +0000
Subject: Bug #78299 [NEW]: Custom entities in attributes are lost while importing
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-221807@lists.php.net to get a copy of this message
From: fabian at leo dot org Operating system: Ubuntu 18.04 PHP version: 7.3.7 Package: DOM XML related Bug Type: Bug Bug description:Custom entities in attributes are lost while importing Description: ------------ When importing a DomNode that contains a custom entity in one of it's attributes, into another DomDocument, the entity is missing from the output of getAttribute(). Note: This is working if the custom entity is already present in the original document. e.g if you add a attribute hack="&lang;" into the root element of the original document, the output of getAttribute on the imported DomNode is as expected "index.php?lang=en" Test script: --------------- <?php // Creating document for import $xml = <<<'XSL' <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE xsl:stylesheet [<!ENTITY lang "lang=en">]> <ex:bla href="index.php?&lang;" xmlns:ex="http://example.com" version="1.0"/> XSL; $source = \DomDocument::loadXml($xml); // Creating original document $xml = <<<'XSL' <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE xsl:stylesheet [<!ENTITY lang "lang=en">]> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:ex="http://example.com" version="1.0"/> XSL; $doc1 = \DomDocument::loadXml($xml); $doc1->documentElement->appendChild($doc1->importNode($source->documentElement)); //echo $doc1->saveXml(); // xml is displayed correct echo $doc1->documentElement->firstChild->getAttribute("href"); // getAttribute() is not working: "index.php?" Expected result: ---------------- index.php?lang=en Actual result: -------------- index.php? -- Edit bug report at https://bugs.php.net/bug.php?id=78299&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=78299&r=trysnapshot54 Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=78299&r=trysnapshot55 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=78299&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=78299&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=78299&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=78299&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=78299&r=needscript Try newer version: https://bugs.php.net/fix.php?id=78299&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=78299&r=support Expected behavior: https://bugs.php.net/fix.php?id=78299&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=78299&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=78299&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=78299&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=78299&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=78299&r=dst IIS Stability: https://bugs.php.net/fix.php?id=78299&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=78299&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=78299&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=78299&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=78299&r=mysqlcfg

« previous php.bugs (#221807) next »