summaryrefslogtreecommitdiff
path: root/ext/xmlwriter
diff options
context:
space:
mode:
authorPierre Joye <pajoye@php.net>2007-05-14 09:23:49 +0000
committerPierre Joye <pajoye@php.net>2007-05-14 09:23:49 +0000
commit19d1d24d60f1c6fb8caf2356f061016925ee4f09 (patch)
tree58366aee2ac3b36a960a02ea94d77e6abbfc6638 /ext/xmlwriter
parentf752fd48365b15da3b38aab536e1a239cb401895 (diff)
downloadphp-git-19d1d24d60f1c6fb8caf2356f061016925ee4f09.tar.gz
- [@DOC] MFH: #41326, better fix. It restores BC and allows both canonical
and short form: - when $content is given, the closing tag will be generated (even for empty string) - when $content is ignored or NULL is given, the short form will be used
Diffstat (limited to 'ext/xmlwriter')
-rw-r--r--ext/xmlwriter/php_xmlwriter.c12
-rw-r--r--ext/xmlwriter/tests/bug41287.phpt12
-rw-r--r--ext/xmlwriter/tests/bug41326.phpt14
3 files changed, 22 insertions, 16 deletions
diff --git a/ext/xmlwriter/php_xmlwriter.c b/ext/xmlwriter/php_xmlwriter.c
index 1d8fd99961..45a0d912c1 100644
--- a/ext/xmlwriter/php_xmlwriter.c
+++ b/ext/xmlwriter/php_xmlwriter.c
@@ -769,7 +769,7 @@ static PHP_FUNCTION(xmlwriter_write_element)
zval *this = getThis();
if (this) {
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|s",
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|s!",
&name, &name_len, &content, &content_len) == FAILURE) {
return;
}
@@ -777,7 +777,7 @@ static PHP_FUNCTION(xmlwriter_write_element)
} else
#endif
{
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rss", &pind,
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs|s!", &pind,
&name, &name_len, &content, &content_len) == FAILURE) {
return;
}
@@ -789,7 +789,7 @@ static PHP_FUNCTION(xmlwriter_write_element)
ptr = intern->ptr;
if (ptr) {
- if (!content || content_len < 1) {
+ if (!content) {
retval = xmlTextWriterStartElement(ptr, (xmlChar *)name);
if (retval == -1) {
RETURN_FALSE;
@@ -824,7 +824,7 @@ static PHP_FUNCTION(xmlwriter_write_element_ns)
zval *this = getThis();
if (this) {
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s!ss!|s",
+ 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;
}
@@ -832,7 +832,7 @@ static PHP_FUNCTION(xmlwriter_write_element_ns)
} else
#endif
{
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs!ss!|s", &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;
}
@@ -844,7 +844,7 @@ static PHP_FUNCTION(xmlwriter_write_element_ns)
ptr = intern->ptr;
if (ptr) {
- if (!content || content_len < 1) {
+ if (!content) {
retval = xmlTextWriterStartElementNS(ptr,(xmlChar *)prefix, (xmlChar *)name, (xmlChar *)uri);
if (retval == -1) {
RETURN_FALSE;
diff --git a/ext/xmlwriter/tests/bug41287.phpt b/ext/xmlwriter/tests/bug41287.phpt
index 3bd09beb84..106ac3a3ec 100644
--- a/ext/xmlwriter/tests/bug41287.phpt
+++ b/ext/xmlwriter/tests/bug41287.phpt
@@ -30,14 +30,14 @@ print $xw->flush(true);
--EXPECTF--
<?xml version="1.0"?>
<test:test xmlns:test="urn:x-test:">
- <test:foo/>
- <bar xmlns="urn:x-test:"/>
- <bar xmlns=""/>
+ <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/>
- <bar xmlns="urn:x-test:"/>
- <bar xmlns=""/>
+ <test:foo></test:foo>
+ <bar xmlns="urn:x-test:"></bar>
+ <bar xmlns=""></bar>
</test:test>
diff --git a/ext/xmlwriter/tests/bug41326.phpt b/ext/xmlwriter/tests/bug41326.phpt
index f4a451fa3c..d7054c81b0 100644
--- a/ext/xmlwriter/tests/bug41326.phpt
+++ b/ext/xmlwriter/tests/bug41326.phpt
@@ -8,7 +8,8 @@ $xml->setIndent(true);
$xml->startDocument();
$xml->startElement('test');
$xml->writeElement('foo', null);
-$xml->writeElement('foo2', null);
+$xml->writeElement('foo2', "");
+$xml->writeElement('foo3');
$xml->startElement('bar');
$xml->endElement('bar');
$xml->endElement();
@@ -23,6 +24,8 @@ $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', 'urn:x-test:', NULL);
+$xw->writeElementNS(null, 'bar', 'urn:x-test:');
$xw->writeElementNS(null, 'bar', '', '');
$xw->endElement();
$xw->endDocument();
@@ -32,13 +35,16 @@ print $xw->flush(true);
<?xml version="1.0"?>
<test>
<foo/>
- <foo2/>
+ <foo2></foo2>
+ <foo3/>
<bar/>
</test>
<?xml version="1.0"?>
<test:test xmlns:test="urn:x-test:">
- <test:foo/>
+ <test:foo></test:foo>
+ <bar xmlns="urn:x-test:"></bar>
<bar xmlns="urn:x-test:"/>
- <bar xmlns=""/>
+ <bar xmlns="urn:x-test:"/>
+ <bar xmlns=""></bar>
</test:test>