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
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: hrpeters at gmx dot net
New email:
PHP Version: OS:

 

 [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: Sat Apr 20 03:01:28 2024 UTC