php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #60931 Entity handling for value in setAttribute() and createElement() differ
Submitted: 2012-01-30 04:06 UTC Modified: 2012-01-30 04:13 UTC
From: hrpeters at gmx dot net Assigned:
Status: Not a bug Package: DOM XML related
PHP Version: 5.3.9 OS: Windows
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
17 - 16 = ?
Subscribe to this entry?

 
 [2012-01-30 04:06 UTC] 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>

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2012-01-30 04:13 UTC] aharvey@php.net
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.
 [2012-01-30 04:13 UTC] aharvey@php.net
-Status: Open +Status: Not a bug
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri May 03 04:01:32 2024 UTC