Bug #60931 [Opn->Nab]: Entity handling for value in setAttribute() and createElement() differ
Edit report at https://bugs.php.net/bug.php?id=60931&edit=1
ID: 60931
Updated by: aharvey@php.net
Reported by: hrpeters at gmx dot net
Summary: Entity handling for value in setAttribute() and
createElement() differ
-Status: Open
+Status: Not a bug
Type: Bug
Package: DOM XML related
Operating System: Windows
PHP Version: 5.3.9
Block user comment: N
Private report: N
New Comment:
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to
report
a bug at http://bugs.php.net/how-to-report.php
This is documented behaviour, per the notes at
http://au2.php.net/domdocument.createElement
-- the node value is not escaped if
you use the non-standard shorthand in the createElement() method.
Previous Comments:
------------------------------------------------------------------------
[2012-01-30 04:06:00] hrpeters at gmx dot net
Description:
------------
Two identical input values with entities create different results depending if they're inserted
as element or attribute into the DOM tree.
Entity handling differs as seen in the output below.
Test script:
---------------
define ('VAL','index.php?e=t&c=au');
$dd = new DOMDocument('1.0', 'UTF-8');
$root = $dd->createElement('root');
$href= $dd->createElement('href',VAL);
$root->setAttribute('href',VAL);
$root->appendChild($href);
$dd->appendChild($root);
echo $dd->saveXML();
Expected result:
----------------
<?xml version="1.0" encoding="UTF-8"?>
<root
href="index.php?e=t&c=au"><href>index.php?e=t&c=au</href></root>
Actual result:
--------------
<?xml version="1.0" encoding="UTF-8"?>
<root
href="index.php?e=t&amp;c=au"><href>index.php?e=t&c=au</href></root>
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=60931&edit=1
Thread (2 messages)