rrichards Fri May 4 20:17:40 2007 UTC Modified files: /php-src/ext/xmlwriter php_xmlwriter.c /php-src/ext/xmlwriter/tests bug41287.phpt Log: MFB: Fix bug #41287 (Namespace functions don't allow xmlns to be optional) add test http://cvs.php.net/viewvc.cgi/php-src/ext/xmlwriter/php_xmlwriter.c?r1=1.45&r2=1.46&diff_format=u Index: php-src/ext/xmlwriter/php_xmlwriter.c diff -u php-src/ext/xmlwriter/php_xmlwriter.c:1.45 php-src/ext/xmlwriter/php_xmlwriter.c:1.46 --- php-src/ext/xmlwriter/php_xmlwriter.c:1.45 Sat Jan 6 18:03:15 2007 +++ php-src/ext/xmlwriter/php_xmlwriter.c Fri May 4 20:17:40 2007 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_xmlwriter.c,v 1.45 2007/01/06 18:03:15 rrichards Exp $ */ +/* $Id: php_xmlwriter.c,v 1.46 2007/05/04 20:17:40 rrichards Exp $ */ #ifdef HAVE_CONFIG_H #include "config.h" @@ -570,7 +570,7 @@ zval *this = getThis(); if (this) { - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s&s&s&", + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s&s&s!&", &prefix, &prefix_len, UG(utf8_conv), &name, &name_len, UG(utf8_conv), &uri, &uri_len, UG(utf8_conv)) == FAILURE) { return; } @@ -578,7 +578,7 @@ } else #endif { - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs&s&s&", &pind, + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs&s&s!&", &pind, &prefix, &prefix_len, UG(utf8_conv), &name, &name_len, UG(utf8_conv), &uri, &uri_len, UG(utf8_conv)) == FAILURE) { return; } @@ -660,7 +660,7 @@ zval *this = getThis(); if (this) { - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s&s&s&s&", + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s&s&s!&s&", &prefix, &prefix_len, UG(utf8_conv), &name, &name_len, UG(utf8_conv), &uri, &uri_len, UG(utf8_conv), &content, &content_len, UG(utf8_conv)) == FAILURE) { return; @@ -669,7 +669,7 @@ } else #endif { - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs&s&s&s&", &pind, + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs&s&s!&s&", &pind, &prefix, &prefix_len, UG(utf8_conv), &name, &name_len, UG(utf8_conv), &uri, &uri_len, UG(utf8_conv), &content, &content_len, UG(utf8_conv)) == FAILURE) { return; @@ -715,7 +715,7 @@ zval *this = getThis(); if (this) { - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s!&s&s&", + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s!&s&s!&", &prefix, &prefix_len, UG(utf8_conv), &name, &name_len, UG(utf8_conv), &uri, &uri_len, UG(utf8_conv)) == FAILURE) { return; } @@ -723,7 +723,7 @@ } else #endif { - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs!&s&s&", &pind, + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs!&s&s!&", &pind, &prefix, &prefix_len, UG(utf8_conv), &name, &name_len, UG(utf8_conv), &uri, &uri_len, UG(utf8_conv)) == FAILURE) { return; } @@ -819,7 +819,7 @@ zval *this = getThis(); if (this) { - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s!&s&s&s&", + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s!&s&s!&s&", &prefix, &prefix_len, UG(utf8_conv), &name, &name_len, UG(utf8_conv), &uri, &uri_len, UG(utf8_conv), &content, &content_len, UG(utf8_conv)) == FAILURE) { return; } @@ -827,7 +827,7 @@ } else #endif { - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs!&s&s&s&", &pind, + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs!&s&s!&s&", &pind, &prefix, &prefix_len, UG(utf8_conv), &name, &name_len, UG(utf8_conv), &uri, &uri_len, UG(utf8_conv), &content, &content_len, UG(utf8_conv)) == FAILURE) { return; } http://cvs.php.net/viewvc.cgi/php-src/ext/xmlwriter/tests/bug41287.phpt?r1=1.1&r2=1.2&diff_format=u Index: php-src/ext/xmlwriter/tests/bug41287.phpt diff -u /dev/null php-src/ext/xmlwriter/tests/bug41287.phpt:1.2 --- /dev/null Fri May 4 20:17:40 2007 +++ php-src/ext/xmlwriter/tests/bug41287.phpt Fri May 4 20:17:40 2007 @@ -0,0 +1,43 @@ +--TEST-- +Bug #41287 (Namespace functions don't allow xmlns defintion to be optional) +--FILE-- +<?php + +$xw = xmlwriter_open_memory(); +xmlwriter_set_indent($xw, true); +xmlwriter_start_document($xw); +xmlwriter_start_element_ns($xw, 'test', 'test', 'urn:x-test:'); +xmlwriter_write_element_ns($xw, 'test', 'foo', null, ''); +xmlwriter_write_element_ns($xw, null, 'bar', 'urn:x-test:', ''); +xmlwriter_write_element_ns($xw, null, 'bar', '', ''); +xmlwriter_end_element($xw); +xmlwriter_end_document($xw); +print xmlwriter_flush($xw, true); +print "\n"; + +$xw = new XMLWriter(); +$xw->openMemory(); +$xw->setIndent(true); +$xw->startDocument(); +$xw->startElementNS('test', 'test', 'urn:x-test:'); +$xw->writeElementNS('test', 'foo', null, ''); +$xw->writeElementNS(null, 'bar', 'urn:x-test:', ''); +$xw->writeElementNS(null, 'bar', '', ''); +$xw->endElement(); +$xw->endDocument(); +print $xw->flush(true); +?> +--EXPECTF-- +<?xml version="1.0"?> +<test:test xmlns:test="urn:x-test:"> + <test:foo></test:foo> + <bar xmlns="urn:x-test:"></bar> + <bar xmlns=""></bar> +</test:test> + +<?xml version="1.0"?> +<test:test xmlns:test="urn:x-test:"> + <test:foo></test:foo> + <bar xmlns="urn:x-test:"></bar> + <bar xmlns=""></bar> +</test:test>
-- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php