From:             jason at amp-design dot net
Operating system: MacOS X / Win 2003 / CentOS
PHP version:      5.0.1
PHP Bug Type:     DOM XML related
Bug description:  DOMCharacterData extending bug

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 &gt; and &lt;
$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&lt;scum /&gt; 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&lt;scum /&gt; ppfgfgf</html>

-- 
Edit bug report at http://bugs.php.net/?id=30530&edit=1
-- 
Try a CVS snapshot (php4):   http://bugs.php.net/fix.php?id=30530&r=trysnapshot4
Try a CVS snapshot (php5.0): http://bugs.php.net/fix.php?id=30530&r=trysnapshot50
Try a CVS snapshot (php5.1): http://bugs.php.net/fix.php?id=30530&r=trysnapshot51
Fixed in CVS:                http://bugs.php.net/fix.php?id=30530&r=fixedcvs
Fixed in release:            http://bugs.php.net/fix.php?id=30530&r=alreadyfixed
Need backtrace:              http://bugs.php.net/fix.php?id=30530&r=needtrace
Need Reproduce Script:       http://bugs.php.net/fix.php?id=30530&r=needscript
Try newer version:           http://bugs.php.net/fix.php?id=30530&r=oldversion
Not developer issue:         http://bugs.php.net/fix.php?id=30530&r=support
Expected behavior:           http://bugs.php.net/fix.php?id=30530&r=notwrong
Not enough info:             http://bugs.php.net/fix.php?id=30530&r=notenoughinfo
Submitted twice:             http://bugs.php.net/fix.php?id=30530&r=submittedtwice
register_globals:            http://bugs.php.net/fix.php?id=30530&r=globals
PHP 3 support discontinued:  http://bugs.php.net/fix.php?id=30530&r=php3
Daylight Savings:            http://bugs.php.net/fix.php?id=30530&r=dst
IIS Stability:               http://bugs.php.net/fix.php?id=30530&r=isapi
Install GNU Sed:             http://bugs.php.net/fix.php?id=30530&r=gnused
Floating point limitations:  http://bugs.php.net/fix.php?id=30530&r=float
MySQL Configuration Error:   http://bugs.php.net/fix.php?id=30530&r=mysqlcfg

Reply via email to