rrichards                                Fri, 02 Apr 2010 16:15:06 +0000

Revision: http://svn.php.net/viewvc?view=revision&revision=297342

Log:
re-apply bug fix #35673 (formatOutput does not work with saveHTML) from old 
trunk
add test
BFN

Bug: http://bugs.php.net/35673 (Closed) formatOutput does not work with saveHTML
      
Changed paths:
    U   php/php-src/branches/PHP_5_3/NEWS
    U   php/php-src/branches/PHP_5_3/ext/dom/document.c
    A   php/php-src/branches/PHP_5_3/ext/dom/tests/bug35673.phpt
    U   php/php-src/trunk/ext/dom/document.c
    A   php/php-src/trunk/ext/dom/tests/bug35673.phpt

Modified: php/php-src/branches/PHP_5_3/NEWS
===================================================================
--- php/php-src/branches/PHP_5_3/NEWS   2010-04-02 15:46:51 UTC (rev 297341)
+++ php/php-src/branches/PHP_5_3/NEWS   2010-04-02 16:15:06 UTC (rev 297342)
@@ -56,8 +56,8 @@
   (yoa...@gmail.com, Derick)
 - Fixed bug #48902 (Timezone database fallback map is outdated). (Derick)
 - Fixed bug #46111 (Some timezone identifiers can not be parsed). (Derick)
+- Fixed bug #35673     (formatOutput does not work with saveHTML). (Rob)

-
 ?? ??? 20??, PHP 5.3.2
 - Upgraded bundled sqlite to version 3.6.22. (Ilia)
 - Upgraded bundled libmagic to version 5.03. (Mikko)

Modified: php/php-src/branches/PHP_5_3/ext/dom/document.c
===================================================================
--- php/php-src/branches/PHP_5_3/ext/dom/document.c     2010-04-02 15:46:51 UTC 
(rev 297341)
+++ php/php-src/branches/PHP_5_3/ext/dom/document.c     2010-04-02 16:15:06 UTC 
(rev 297342)
@@ -2286,7 +2286,8 @@
        xmlDoc *docp;
        dom_object *intern;
        xmlChar *mem;
-       int size;
+       int size, format;
+       dom_doc_propsptr doc_props;

        if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), 
"O", &id, dom_document_class_entry) == FAILURE) {
                return;
@@ -2294,7 +2295,13 @@

        DOM_GET_OBJ(docp, id, xmlDocPtr, intern);

+#if LIBXML_VERSION >= 20623
+       doc_props = dom_get_doc_props(intern->document);
+       format = doc_props->formatoutput;
+       htmlDocDumpMemoryFormat(docp, &mem, &size, format);
+#else
        htmlDocDumpMemory(docp, &mem, &size);
+#endif
        if (!size) {
                if (mem)
                        xmlFree(mem);

Added: php/php-src/branches/PHP_5_3/ext/dom/tests/bug35673.phpt
===================================================================
--- php/php-src/branches/PHP_5_3/ext/dom/tests/bug35673.phpt                    
        (rev 0)
+++ php/php-src/branches/PHP_5_3/ext/dom/tests/bug35673.phpt    2010-04-02 
16:15:06 UTC (rev 297342)
@@ -0,0 +1,20 @@
+--TEST--
+Bug #35673 (formatOutput does not work with saveHTML).
+--SKIPIF--
+<?php require_once('skipif.inc'); ?>
+--FILE--
+<?php
+$html = '<html><head><meta http-equiv="Content-Type" content="text/html; 
charset=UTF-8">
+<title>This is the title</title></head></html>';
+
+$htmldoc = new DOMDocument();
+$htmldoc->loadHTML($html);
+$htmldoc->formatOutput = true;
+echo $htmldoc->saveHTML();
+?>
+--EXPECT--
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" 
"http://www.w3.org/TR/REC-html40/loose.dtd";>
+<html><head>
+<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+<title>This is the title</title>
+</head></html>

Modified: php/php-src/trunk/ext/dom/document.c
===================================================================
--- php/php-src/trunk/ext/dom/document.c        2010-04-02 15:46:51 UTC (rev 
297341)
+++ php/php-src/trunk/ext/dom/document.c        2010-04-02 16:15:06 UTC (rev 
297342)
@@ -2286,7 +2286,8 @@
        xmlDoc *docp;
        dom_object *intern;
        xmlChar *mem;
-       int size;
+       int size, format;
+       dom_doc_propsptr doc_props;

        if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), 
"O", &id, dom_document_class_entry) == FAILURE) {
                return;
@@ -2294,7 +2295,13 @@

        DOM_GET_OBJ(docp, id, xmlDocPtr, intern);

+#if LIBXML_VERSION >= 20623
+       doc_props = dom_get_doc_props(intern->document);
+       format = doc_props->formatoutput;
+       htmlDocDumpMemoryFormat(docp, &mem, &size, format);
+#else
        htmlDocDumpMemory(docp, &mem, &size);
+#endif
        if (!size) {
                if (mem)
                        xmlFree(mem);

Added: php/php-src/trunk/ext/dom/tests/bug35673.phpt
===================================================================
--- php/php-src/trunk/ext/dom/tests/bug35673.phpt                               
(rev 0)
+++ php/php-src/trunk/ext/dom/tests/bug35673.phpt       2010-04-02 16:15:06 UTC 
(rev 297342)
@@ -0,0 +1,20 @@
+--TEST--
+Bug #35673 (formatOutput does not work with saveHTML).
+--SKIPIF--
+<?php require_once('skipif.inc'); ?>
+--FILE--
+<?php
+$html = '<html><head><meta http-equiv="Content-Type" content="text/html; 
charset=UTF-8">
+<title>This is the title</title></head></html>';
+
+$htmldoc = new DOMDocument();
+$htmldoc->loadHTML($html);
+$htmldoc->formatOutput = true;
+echo $htmldoc->saveHTML();
+?>
+--EXPECT--
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" 
"http://www.w3.org/TR/REC-html40/loose.dtd";>
+<html><head>
+<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+<title>This is the title</title>
+</head></html>

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

Reply via email to