From:             jfowlie at navarik dot com
Operating system: Linux
PHP version:      5.1.4
PHP Bug Type:     DOM XML related
Bug description:  Timeout when setting nodeValue if entity in existing value

Description:
------------
I was attempting to update the content of some anchor elements by setting
the nodeValue. It doesn't seem to matter how high I set the
max_execution_time limit, if there is a   entity in the nodeValue,
PHP just hangs until it times out. (It works just fine with &
though...)


Reproduce code:
---------------
<?php
$xhtml = <<<XHTML
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";>
<html xmlns="http://www.w3.org/1999/xhtml";>
<head>
<title>Untitled</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"
/>
</head>
<body>
<a href="#" id="id-goes-here">Link 1</a>
<a href="#" id="id-2-goes-here">Link 2 &amp;</a>
<a href="#" id="id-3-goes-here">Link 3 &nbsp;</a>
</body>
</html>
XHTML;


$dom = new DOMDocument('1.0','iso-8859-1');

// I tried it with this set to true or false
//$xml->preserveWhiteSpace = FALSE;

// You need this, otherwise the nbsp entity is not valid
$dom->resolveExternals = TRUE;

$dom->loadXML($xhtml);

$bookmarks = $dom->getElementsByTagName('a');

$count = 0;

foreach($bookmarks as $bookmark_node){
        ++$count;
        $id_value = $bookmark_node->getAttribute('id');
        print "Id value: ".$id_value."<br />";
        print "Node value: ".$bookmark_node->nodeValue."<br />";
        print "Setting nodeValue to 'test$count'<br />";
        $bookmark_node->nodeValue = 'test'.$count;
        print "Node value has been set! ({$bookmark_node->nodeValue})<hr
/>";
}
?>


Expected result:
----------------
Id value: id-goes-here
Node value: Link 1
Setting nodeValue to 'test1'
Node value has been set! (test1)

Id value: id-2-goes-here
Node value: Link 2 &
Setting nodeValue to 'test2'
Node value has been set! (test2)

Id value: id-3-goes-here
Node value: Link 3
Setting nodeValue to 'test3'
Node value has been set! (test3)


Actual result:
--------------
Id value: id-goes-here
Node value: Link 1
Setting nodeValue to 'test1'
Node value has been set! (test1)

Id value: id-2-goes-here
Node value: Link 2 &
Setting nodeValue to 'test2'
Node value has been set! (test2)

Id value: id-3-goes-here
Node value: Link 3
Setting nodeValue to 'test3'

Fatal error: Maximum execution time of 30 seconds exceeded in
nbsp-dom-test.php on line 39


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

Reply via email to