From: sgunderson at bigfoot dot com Operating system: Debian PHP version: 5.3CVS-2009-02-28 (snap) PHP Bug Type: DOM XML related Bug description: DOMAttribute value getter and setter do not escape equally
Description: ------------ When you fetch the "value" field of a DOMAttribute, it seems to unescape any HTML (or perhaps XML?) entities present. However, when you set it, it does not get escaped. In other words, if you do "$attr->value = $attr->value" (which really should be a no-op!) as in the example below, you will get errors if it happened to contain &. Verified with PHP 5.2.6 and 5.3.0 snap (2008-02-28). Reproduce code: --------------- <?php $doc = new DOMDocument; $doc->loadXML('<html><element /></html>'); $elem = $doc->documentElement->firstChild; $attr = $doc->createAttribute("foo"); $attr->value = "foo&bar"; $attr->value = $attr->value; $elem->appendChild($attr); print $doc->saveXML(); ?> Expected result: ---------------- <?xml version="1.0"?> <html><element foo="foo&bar"/></html> Actual result: -------------- Warning: main(): unterminated entity reference bar in /home/sesse/test3.php on line 8 <?xml version="1.0"?> <html><element foo="foo"/></html> -- Edit bug report at http://bugs.php.net/?id=47532&edit=1 -- Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=47532&r=trysnapshot52 Try a CVS snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=47532&r=trysnapshot53 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=47532&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=47532&r=fixedcvs Fixed in CVS and need be documented: http://bugs.php.net/fix.php?id=47532&r=needdocs Fixed in release: http://bugs.php.net/fix.php?id=47532&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=47532&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=47532&r=needscript Try newer version: http://bugs.php.net/fix.php?id=47532&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=47532&r=support Expected behavior: http://bugs.php.net/fix.php?id=47532&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=47532&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=47532&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=47532&r=globals PHP 4 support discontinued: http://bugs.php.net/fix.php?id=47532&r=php4 Daylight Savings: http://bugs.php.net/fix.php?id=47532&r=dst IIS Stability: http://bugs.php.net/fix.php?id=47532&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=47532&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=47532&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=47532&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=47532&r=mysqlcfg