]> granicus.if.org Git - php/commitdiff
MFB: Fix bug #41287 (Namespace functions don't allow xmlns to be optional)
authorRob Richards <rrichards@php.net>
Fri, 4 May 2007 20:17:40 +0000 (20:17 +0000)
committerRob Richards <rrichards@php.net>
Fri, 4 May 2007 20:17:40 +0000 (20:17 +0000)
add test

ext/xmlwriter/php_xmlwriter.c
ext/xmlwriter/tests/bug41287.phpt [new file with mode: 0644]

index 1ac64c4f39b2f1496d14928abaa9e7584960ddba..5e6235eb56a5b3f007fdd6386aa671514be3dc67 100644 (file)
@@ -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 (file)
index 0000000..106ac3a
--- /dev/null
@@ -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>