ID: 30530
Comment by: Jason at amp-design dot net
Reported By: jason at amp-design dot net
Status: Open
Bug Type: DOM XML related
Operating System: MacOS X / Win 2003 / CentOS
PHP Version: 5.0.1
New Comment:
Just out of interest, would this be to do with the fact there is no XML
Constant related to DOMCharacterData nodes, where as other nodes do
(e.g. DOMElement will have a node type of XML_ELEMENT_NODE).
Previous Comments:
------------------------------------------------------------------------
[2004-10-22 12:19:37] jason at amp-design dot net
Description:
------------
In my example code class RawStuff extends DOMCharacterData and creates
a fetch error, which I can't see why it's happening (nothing in the PHP
manual or DOM specs seems to say anything as far as I can see).
If I change the code to
class RawStuff extends DOMText
then the code doesn't error, however I don't want it to escape the <
and > characters, which is why I want to extend from DOMCharacterData
as this shouldn't escape < and > (coz it doesn't in DOMComment and that
extends DOMCharacterData).
As far as I can see this seems to be a bug though, there maybe some
good reason why this doesn't work, however there seems to be no
mentioning of it in both the DOM Spec of PHP manual.
Reproduce code:
---------------
<?php
header('Content-type: text/plain');
class RawStuff extends DOMCharacterData {
public $poop;
}
class NiceElement extends DOMElement {
}
$o = new DOMDocument();
// Expecting <scum /> to be escaped here with > and <
$p = new NiceElement('html', ' ppp<scum /> pp', '12121212');
$o->appendChild($p);
// Not expecting <% and %> to be escaped as DOMComment extends the
DOMCharacterData class
// and this allows things like <!-- <scum /> --> without turning < and
> into entites
// However we can't use DOMCharacterData directly without a fetch error
for some reason
$cack = &new RawStuff('blah some node which can also hold raw <% asp
data %>');
$p->appendChild($cack);
$cack2 = $o->createTextNode('fgfgf');
$p->appendChild($cack2);
echo $o->saveXML();
?>
Expected result:
----------------
<?xml version="1.0"?>
<html xmlns="12121212"> ppp<scum /> ppblah some node which can
also hold raw <% asp data %>fgfgf</html>
Actual result:
--------------
<br />
<b>Warning</b>: Couldn't fetch RawStuff in
<b>/data/web/test_stuff/DOM_test.php</b> on line <b>22</b><br />
<?xml version="1.0"?>
<html xmlns="12121212"> ppp<scum /> ppfgfgf</html>
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=30530&edit=1