diff options
author | Rob Richards <rrichards@php.net> | 2007-05-04 20:16:39 +0000 |
---|---|---|
committer | Rob Richards <rrichards@php.net> | 2007-05-04 20:16:39 +0000 |
commit | 78ccf4e0c232fe319c3036d4095b6bcbddd481a0 (patch) | |
tree | 8c2853c36dab4e81ec2b7907080eb5e34407c7c6 /ext/xmlwriter | |
parent | 3585581412389845c674809726b377006b2d99b1 (diff) | |
download | php-git-78ccf4e0c232fe319c3036d4095b6bcbddd481a0.tar.gz |
Fix bug #41287 (Namespace functions don't allow xmlns to be optional)
add test
Diffstat (limited to 'ext/xmlwriter')
-rw-r--r-- | ext/xmlwriter/php_xmlwriter.c | 16 | ||||
-rw-r--r-- | ext/xmlwriter/tests/bug41287.phpt | 43 |
2 files changed, 51 insertions, 8 deletions
diff --git a/ext/xmlwriter/php_xmlwriter.c b/ext/xmlwriter/php_xmlwriter.c index ac823b217b..169ae0b1a8 100644 --- a/ext/xmlwriter/php_xmlwriter.c +++ b/ext/xmlwriter/php_xmlwriter.c @@ -566,7 +566,7 @@ static PHP_FUNCTION(xmlwriter_start_attribute_ns) zval *this = getThis(); if (this) { - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sss", + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sss!", &prefix, &prefix_len, &name, &name_len, &uri, &uri_len) == FAILURE) { return; } @@ -574,7 +574,7 @@ static PHP_FUNCTION(xmlwriter_start_attribute_ns) } else #endif { - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rsss", &pind, + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rsss!", &pind, &prefix, &prefix_len, &name, &name_len, &uri, &uri_len) == FAILURE) { return; } @@ -656,7 +656,7 @@ static PHP_FUNCTION(xmlwriter_write_attribute_ns) zval *this = getThis(); if (this) { - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ssss", + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sss!s", &prefix, &prefix_len, &name, &name_len, &uri, &uri_len, &content, &content_len) == FAILURE) { return; } @@ -664,7 +664,7 @@ static PHP_FUNCTION(xmlwriter_write_attribute_ns) } else #endif { - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rssss", &pind, + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rsss!s", &pind, &prefix, &prefix_len, &name, &name_len, &uri, &uri_len, &content, &content_len) == FAILURE) { return; } @@ -709,7 +709,7 @@ static PHP_FUNCTION(xmlwriter_start_element_ns) zval *this = getThis(); if (this) { - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s!ss", + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s!ss!", &prefix, &prefix_len, &name, &name_len, &uri, &uri_len) == FAILURE) { return; } @@ -717,7 +717,7 @@ static PHP_FUNCTION(xmlwriter_start_element_ns) } else #endif { - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs!ss", &pind, + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs!ss!", &pind, &prefix, &prefix_len, &name, &name_len, &uri, &uri_len) == FAILURE) { return; } @@ -813,7 +813,7 @@ static PHP_FUNCTION(xmlwriter_write_element_ns) zval *this = getThis(); if (this) { - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s!sss", + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s!ss!s", &prefix, &prefix_len, &name, &name_len, &uri, &uri_len, &content, &content_len) == FAILURE) { return; } @@ -821,7 +821,7 @@ static PHP_FUNCTION(xmlwriter_write_element_ns) } else #endif { - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs!sss", &pind, + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs!ss!s", &pind, &prefix, &prefix_len, &name, &name_len, &uri, &uri_len, &content, &content_len) == 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-- +<?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> |