From bc9f8f582cefd55140d00d731949502f1e66f9b9 Mon Sep 17 00:00:00 2001 From: Ilia Alshanetsky Date: Tue, 24 Apr 2007 13:54:59 +0000 Subject: [PATCH] Fixed bug #41175 (addAttribute() fails to add an attribute with an empty value). --- NEWS | 2 ++ ext/simplexml/simplexml.c | 2 +- ext/simplexml/tests/bug41175.phpt | 16 ++++++++++++++++ 3 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 ext/simplexml/tests/bug41175.phpt diff --git a/NEWS b/NEWS index 517a0347bf0..82ad9200846 100644 --- 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 diff --git a/ext/simplexml/simplexml.c b/ext/simplexml/simplexml.c index 2c919ea24fa..0b0f9ff54bc 100644 --- a/ext/simplexml/simplexml.c +++ b/ext/simplexml/simplexml.c @@ -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 index 00000000000..51181d29c03 --- /dev/null +++ b/ext/simplexml/tests/bug41175.phpt @@ -0,0 +1,16 @@ +--TEST-- +Bug #41175 (addAttribute() fails to add an attribute with an empty value) +--FILE-- +"); +$xml->addAttribute("src", "foo"); +$xml->addAttribute("alt", ""); +echo $xml->asXML(); + +echo "Done\n"; +?> +--EXPECT-- + + +Done \ No newline at end of file