|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #14325 set_attribute does not keep '&' in character references
Submitted: 2001-12-03 11:39 UTC Modified: 2001-12-03 17:53 UTC
From: andrew at boxuk dot com Assigned:
Status: Not a bug Package: DOM XML related
PHP Version: 4.0.5 OS: Redhat 7.0
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:
Solve the problem:
33 - 12 = ?
Subscribe to this entry?

 [2001-12-03 11:39 UTC] andrew at boxuk dot com
The '&' in character references is converted to & when used in set_attribute
e.g. ! is changed to !

$oXml      = new_xmldoc("1.0");           
$oRoot     = $oXml->add_root("outputXml");
print $oXml->dumpmem();

This produces 
<?xml version="1.0"?>
<outputXml test="&amp;033;"/>

instead of
<?xml version="1.0"?>
<outputXml test="&033;"/>

PHP modules compiled:
'./configure' '--prefix=/usr' '--with-apxs=/usr/sbin/apxs' '--with-exec-dir=/usr/bin' '--with-config-file-path=/etc/httpd' '--with-regex=system' '--enable-debugger' '--enable-magic-quotes' '--enable-sysvshm' '--with-dom' '--enable-force-cgi-redirect' '--enable-sigchild' '--with-wddx' '--enable-inline-optimization' '--with-gnu-ld' '--enable-bcmath' '--enable-crypt' '--with-xml' '--with-sablot' '--enable-dbg=shared' '--with-dbg-profiler'


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2001-12-03 17:53 UTC]
You actually ran into a feature of libxml2. It does automatic character encoding. I remember it was discussed to implement a function to set raw attributes but as far as I know the current version it's not implemented so there's little we can do about it (but I would be happy to be proved being wrong here).

Not a PHP bug -> bogusifying.
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon May 27 00:01:31 2024 UTC