]> granicus.if.org Git - php/commitdiff
re-apply bug fix #35673 (formatOutput does not work with saveHTML) from old trunk
authorRob Richards <rrichards@php.net>
Fri, 2 Apr 2010 16:15:06 +0000 (16:15 +0000)
committerRob Richards <rrichards@php.net>
Fri, 2 Apr 2010 16:15:06 +0000 (16:15 +0000)
add test
BFN

NEWS
ext/dom/document.c
ext/dom/tests/bug35673.phpt [new file with mode: 0644]

diff --git a/NEWS b/NEWS
index 326830246f426441c94c7bf525f8b22bb678bce7..013528da476428f089a8bce0416ee05b50dfb5ce 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -56,7 +56,7 @@ PHP                                                                        NEWS
   (yoarvi@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)
index 8b212ed03ec8ada38eec80e67a4b6ae2229faff6..5b8e3c6efa740b94e8ca49ad31971a521b7f3536 100644 (file)
@@ -2286,7 +2286,8 @@ PHP_FUNCTION(dom_document_save_html)
        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 @@ PHP_FUNCTION(dom_document_save_html)
 
        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);
diff --git a/ext/dom/tests/bug35673.phpt b/ext/dom/tests/bug35673.phpt
new file mode 100644 (file)
index 0000000..a29ae96
--- /dev/null
@@ -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>