From bb12eaa1e959e766e7cd1f1d781f5c0f732331c4 Mon Sep 17 00:00:00 2001 From: Rob Richards Date: Fri, 4 May 2007 20:17:40 +0000 Subject: [PATCH] MFB: Fix bug #41287 (Namespace functions don't allow xmlns to be optional) add test --- ext/xmlwriter/php_xmlwriter.c | 16 ++++++------ ext/xmlwriter/tests/bug41287.phpt | 43 +++++++++++++++++++++++++++++++ 2 files changed, 51 insertions(+), 8 deletions(-) create mode 100644 ext/xmlwriter/tests/bug41287.phpt diff --git a/ext/xmlwriter/php_xmlwriter.c b/ext/xmlwriter/php_xmlwriter.c index 1ac64c4f39..5e6235eb56 100644 --- a/ext/xmlwriter/php_xmlwriter.c +++ b/ext/xmlwriter/php_xmlwriter.c @@ -570,7 +570,7 @@ static PHP_FUNCTION(xmlwriter_start_attribute_ns) 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 @@ static PHP_FUNCTION(xmlwriter_start_attribute_ns) } 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 @@ static PHP_FUNCTION(xmlwriter_write_attribute_ns) 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 @@ static PHP_FUNCTION(xmlwriter_write_attribute_ns) } 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 @@ static PHP_FUNCTION(xmlwriter_start_element_ns) 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 @@ static PHP_FUNCTION(xmlwriter_start_element_ns) } 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 @@ static PHP_FUNCTION(xmlwriter_write_element_ns) 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 @@ static PHP_FUNCTION(xmlwriter_write_element_ns) } 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; } diff --git a/ext/xmlwriter/tests/bug41287.phpt b/ext/xmlwriter/tests/bug41287.phpt new file mode 100644 index 0000000000..106ac3a3ec --- /dev/null +++ b/ext/xmlwriter/tests/bug41287.phpt @@ -0,0 +1,43 @@ +--TEST-- +Bug #41287 (Namespace functions don't allow xmlns defintion to be optional) +--FILE-- +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-- + + + + + + + + + + + + + -- 2.50.1