Bug #79684 [NEW]: C14N sorts the attributes (incorrectly) when not loaded
From: and_spam+php_net at rump dot dk
Operating system: Linux
PHP version: 7.3.18
Package: DOM XML related
Bug Type: Bug
Bug description:C14N sorts the attributes (incorrectly) when not loaded
Description:
------------
The test script perform the same operation twice but the result (the
last two lines) are different depending on if the XML has been created
dynamically or loaded (in this case by storing the dynamically created
XML and (re)loading it).
You may reorder the createAttribute lines as you want but the last two
lines will always be the same - the last line being correct.
Test script:
---------------
$xml = new DOMDocument();
$element = $xml->createElement('saml:Assertion');
$xml_saml_assertion = $xml->appendChild($element);
$attribute = $xml->createAttribute('id');
$attribute->value = 'IDCard';
$xml_saml_assertion->appendChild($attribute);
$attribute = $xml->createAttribute('xmlns:saml');
$attribute->value = 'urn:oasis:names:tc:SAML:2.0:assertion';
$xml_saml_assertion->appendChild($attribute);
$attribute = $xml->createAttribute('Version');
$attribute->value = '2.0';
$xml_saml_assertion->appendChild($attribute);
print("<pre>" . htmlentities($xml->saveXML()) .
"</pre><br>\n");
print("<pre>" . htmlentities($xml->C14N(TRUE)) .
"</pre><br>\n");
$xml->loadXML($xml->saveXML());
print("<pre>" . htmlentities($xml->C14N(TRUE)) .
"</pre><br>\n");
Expected result:
----------------
<saml:Assertion xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion"
Version="2.0" id="IDCard"></saml:Assertion>
Actual result:
--------------
<saml:Assertion Version="2.0" id="IDCard"
xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion"></saml:Assertion>
--
Edit bug report at https://bugs.php.net/bug.php?id=79684&edit=1
--
Fix committed: https://bugs.php.net/fix.php?id=79684&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=79684&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=79684&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=79684&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=79684&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=79684&r=support
Expected behavior: https://bugs.php.net/fix.php?id=79684&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=79684&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=79684&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=79684&r=globals
PHP version support discontinued: https://bugs.php.net/fix.php?id=79684&r=phptooold
Daylight Savings: https://bugs.php.net/fix.php?id=79684&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=79684&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=79684&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=79684&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=79684&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=79684&r=mysqlcfg
Thread (7 messages)
- and_spam+php_net at rump dot dk