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

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

index ac823b217b38f38173d0191065e9ae6bb9d00630..169ae0b1a8dfbd41937472096e6f42324e557ba7 100644 (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;
                }
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>