Fix bug #41287 (Namespace functions don't allow xmlns to be optional)

add test
This commit is contained in:
Rob Richards 2007-05-04 20:16:39 +00:00
parent 3585581412
commit 78ccf4e0c2
2 changed files with 51 additions and 8 deletions

View File

@ -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;
}

View File

@ -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>