Bug #60931 [Opn->Nab]: Entity handling for value in setAttribute() and createElement() differ

From: Date: Mon, 30 Jan 2012 04:13:44 +0000
Subject: Bug #60931 [Opn->Nab]: Entity handling for value in setAttribute() and createElement() differ
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-166942@lists.php.net to get a copy of this message
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&amp;c=au"><href>index.php?e=t&amp;c=au</href></root>

Actual result:
--------------
<?xml version="1.0" encoding="UTF-8"?>
<root
href="index.php?e=t&amp;amp;c=au"><href>index.php?e=t&amp;c=au</href></root>


------------------------------------------------------------------------



-- 
Edit this bug report at https://bugs.php.net/bug.php?id=60931&edit=1


Thread (2 messages)

« previous php.bugs (#166942) next »