rrichards Mon Nov 12 18:58:01 2007 UTC Added files: /php-src/ext/simplexml/tests bug43221.phpt
Modified files: /php-src/ext/simplexml simplexml.c Log: fix bug #43221 (SimpleXML adding default namespace in addAttribute) add test http://cvs.php.net/viewvc.cgi/php-src/ext/simplexml/simplexml.c?r1=1.245&r2=1.246&diff_format=u Index: php-src/ext/simplexml/simplexml.c diff -u php-src/ext/simplexml/simplexml.c:1.245 php-src/ext/simplexml/simplexml.c:1.246 --- php-src/ext/simplexml/simplexml.c:1.245 Sun Oct 7 05:15:04 2007 +++ php-src/ext/simplexml/simplexml.c Mon Nov 12 18:58:01 2007 @@ -18,7 +18,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: simplexml.c,v 1.245 2007/10/07 05:15:04 davidw Exp $ */ +/* $Id: simplexml.c,v 1.246 2007/11/12 18:58:01 rrichards Exp $ */ #ifdef HAVE_CONFIG_H #include "config.h" @@ -1697,6 +1697,13 @@ localname = xmlSplitQName2((xmlChar *)qname, &prefix); if (localname == NULL) { + if (nsuri_len > 0) { + if (prefix != NULL) { + xmlFree(prefix); + } + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Attribute requires prefix for namespace"); + return; + } localname = xmlStrdup((xmlChar *)qname); } @@ -2503,7 +2510,7 @@ { php_info_print_table_start(); php_info_print_table_header(2, "Simplexml support", "enabled"); - php_info_print_table_row(2, "Revision", "$Revision: 1.245 $"); + php_info_print_table_row(2, "Revision", "$Revision: 1.246 $"); php_info_print_table_row(2, "Schema support", #ifdef LIBXML_SCHEMAS_ENABLED "enabled"); http://cvs.php.net/viewvc.cgi/php-src/ext/simplexml/tests/bug43221.phpt?view=markup&rev=1.1 Index: php-src/ext/simplexml/tests/bug43221.phpt +++ php-src/ext/simplexml/tests/bug43221.phpt --TEST-- Bug #43221 (SimpleXML adding default namespace in addAttribute) --FILE-- <?php $xml = simplexml_load_string('<?xml version="1.0" encoding="utf-8"?><root />'); $n = $xml->addChild("node", "value"); $n->addAttribute("a", "b"); $n->addAttribute("c", "d", "http://bar.com"); $n->addAttribute("foo:e", "f", "http://bar.com"); print_r($xml->asXml()); ?> --EXPECTF-- Warning: SimpleXMLElement::addAttribute(): Attribute requires prefix for namespace in %sbug43221.php on line %d <?xml version="1.0" encoding="utf-8"?> <root><node xmlns:foo="http://bar.com" a="b" foo:e="f">value</node></root> -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php