]> granicus.if.org Git - php/commitdiff
Fixed bug #41175 (addAttribute() fails to add an attribute with an empty
authorIlia Alshanetsky <iliaa@php.net>
Tue, 24 Apr 2007 13:54:59 +0000 (13:54 +0000)
committerIlia Alshanetsky <iliaa@php.net>
Tue, 24 Apr 2007 13:54:59 +0000 (13:54 +0000)
value).

NEWS
ext/simplexml/simplexml.c
ext/simplexml/tests/bug41175.phpt [new file with mode: 0644]

diff --git a/NEWS b/NEWS
index 517a0347bf000ed9200689747b1e94f96c54125c..82ad920084665db2b8c2487bf9137be051dc8021 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -4,6 +4,8 @@ PHP                                                                        NEWS
 - Fixed commandline handling fro CLI and CGI. (Marcus, Johannes)
 - Upgraded SQLite 3 to version 3.3.16 (Ilia)
 - Updated timezone database to version 2007.5. (Derick)
+- Fixed bug #41175 (addAttribute() fails to add an attribute with an empty
+  value). (Ilia)
 - Fixed bug #41159 (mysql_pconnect() hash does not account for connect
   flags). (Ilia)
 - Fixed bug #41121 (range() overflow handling for large numbers on 32bit
index 2c919ea24fa654988fa8bbb336f12cb5112c9911..0b0f9ff54bc8105527c0de96b07b1278f61076b3 100644 (file)
@@ -1542,7 +1542,7 @@ SXE_METHOD(addAttribute)
                return;
        }
 
-       if (qname_len == 0 || value_len == 0) {
+       if (qname_len == 0) {
                php_error_docref(NULL TSRMLS_CC, E_WARNING, "Attribute name and value are required");
                return;
        }
diff --git a/ext/simplexml/tests/bug41175.phpt b/ext/simplexml/tests/bug41175.phpt
new file mode 100644 (file)
index 0000000..51181d2
--- /dev/null
@@ -0,0 +1,16 @@
+--TEST--
+Bug #41175 (addAttribute() fails to add an attribute with an empty value)
+--FILE--
+<?php
+
+$xml = new SimpleXmlElement("<img></img>");
+$xml->addAttribute("src", "foo");
+$xml->addAttribute("alt", "");
+echo $xml->asXML();
+
+echo "Done\n";
+?>
+--EXPECT--     
+<?xml version="1.0"?>
+<img src="foo" alt=""/>
+Done
\ No newline at end of file