rrichards               Mon Nov 13 20:47:52 2006 UTC

  Added files:                 
    /php-src/ext/xmlwriter/tests        bug39504.phpt 

  Modified files:              
    /php-src/ext/xmlwriter      php_xmlwriter.c 
  Log:
  Fixed bug #39504 (xmlwriter_write_dtd_entity() creates Attlist tag, 
   not enity). (Hannes Magnusson)
  add test
  
http://cvs.php.net/viewvc.cgi/php-src/ext/xmlwriter/php_xmlwriter.c?r1=1.41&r2=1.42&diff_format=u
Index: php-src/ext/xmlwriter/php_xmlwriter.c
diff -u php-src/ext/xmlwriter/php_xmlwriter.c:1.41 
php-src/ext/xmlwriter/php_xmlwriter.c:1.42
--- php-src/ext/xmlwriter/php_xmlwriter.c:1.41  Thu Nov  9 20:02:23 2006
+++ php-src/ext/xmlwriter/php_xmlwriter.c       Mon Nov 13 20:47:52 2006
@@ -17,7 +17,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: php_xmlwriter.c,v 1.41 2006/11/09 20:02:23 bjori Exp $ */
+/* $Id: php_xmlwriter.c,v 1.42 2006/11/13 20:47:52 rrichards Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -370,7 +370,7 @@
 }
 /* }}} */
 
-/* {{{ xmlwriter_objects_clone */
+/* {{{ php_xmlwriter_streams_IO_close */
 static int php_xmlwriter_streams_IO_close(void *context)
 {
        TSRMLS_FETCH();
@@ -1355,7 +1355,7 @@
 }
 /* }}} */
 
-/* {{{ proto bool xmlwriter_write_dtd_entity(resource xmlwriter, string name, 
string content) U
+/* {{{ proto bool xmlwriter_write_dtd_entity(resource xmlwriter, string name, 
string content [, int pe [, string pubid [, string sysid [, string ndataid]]]]) 
U
 Write full DTD Entity tag - returns FALSE on error */
 static PHP_FUNCTION(xmlwriter_write_dtd_entity)
 {
@@ -1364,22 +1364,29 @@
        xmlTextWriterPtr ptr;
        char *name, *content;
        int name_len, content_len, retval;
+       /* Optional parameters */
+       char *pubid = NULL, *sysid = NULL, *ndataid = NULL;
+       int pe = 0, pubid_len, sysid_len, ndataid_len;
 
 #ifdef ZEND_ENGINE_2
        zval *this = getThis();
 
        if (this) {
                if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s&s&",
-                       &name, &name_len, UG(utf8_conv), &content, 
&content_len, UG(utf8_conv)) == FAILURE) {
+                       &name, &name_len, UG(utf8_conv), &content, 
&content_len, UG(utf8_conv),
+                       &pe, UG(utf8_conv), &pubid, &pubid_len, UG(utf8_conv), 
&sysid, &sysid_len, UG(utf8_conv),
+                       UG(utf8_conv), &ndataid, &ndataid_len) == FAILURE) {
                        return;
                }
                XMLWRITER_FROM_OBJECT(intern, this);
        } else
 #endif
        {
-               if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs&s&", 
&pind, 
-                       &name, &name_len, UG(utf8_conv), &content, 
&content_len, UG(utf8_conv)) == FAILURE) {
-                       return;
+               if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, 
"rs&s&|ls&s&s&", &pind, 
+                       &name, &name_len, UG(utf8_conv), &content, 
&content_len, UG(utf8_conv),
+                       &pe, UG(utf8_conv), &pubid, &pubid_len, UG(utf8_conv), 
&sysid, &sysid_len, UG(utf8_conv),
+                       UG(utf8_conv), &ndataid, &ndataid_len) == FAILURE) {
+                       return;
                }
                ZEND_FETCH_RESOURCE(intern,xmlwriter_object *, &pind, -1, 
"XMLWriter", le_xmlwriter);
        }
@@ -1389,7 +1396,7 @@
        ptr = intern->ptr;
 
        if (ptr) {
-               retval = xmlTextWriterWriteDTDAttlist(ptr, (xmlChar *)name, 
(xmlChar *)content);
+               retval = xmlTextWriterWriteDTDEntity(ptr, pe, (xmlChar *)name, 
(xmlChar *)pubid, (xmlChar *)sysid, (xmlChar *)ndataid, (xmlChar *)content);
                if (retval != -1) {
                        RETURN_TRUE;
                }

http://cvs.php.net/viewvc.cgi/php-src/ext/xmlwriter/tests/bug39504.phpt?view=markup&rev=1.1
Index: php-src/ext/xmlwriter/tests/bug39504.phpt
+++ php-src/ext/xmlwriter/tests/bug39504.phpt
--TEST--
bug# 39504 (xmlwriter_write_dtd_entity() creates Attlist tag, not enity)
--FILE--
<?php

$xw = xmlwriter_open_memory();
xmlwriter_start_document($xw, NULL, "UTF-8");
xmlwriter_start_dtd($xw, "root");
xmlwriter_write_dtd_entity($xw, "ent2", "val2");
xmlwriter_end_dtd($xw);
xmlwriter_start_element($xw, "root");
xmlwriter_end_document($xw);
print xmlwriter_flush($xw, true);

?>
--EXPECTF--
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE root [<!ENTITY ent2 "val2">]><root/>

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to