|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2010-02-14 13:31 UTC] rrichards@php.net
[2010-05-31 08:53 UTC] nospaces at eatmorespuds dot com
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Nov 01 00:00:01 2025 UTC |
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>