]> granicus.if.org Git - php/commitdiff
- Hopefully finally fixed the mess in rev 307562 and rev 307563.
authorGustavo André dos Santos Lopes <cataphract@php.net>
Wed, 19 Jan 2011 00:22:06 +0000 (00:22 +0000)
committerGustavo André dos Santos Lopes <cataphract@php.net>
Wed, 19 Jan 2011 00:22:06 +0000 (00:22 +0000)
ext/dom/document.c
ext/dom/tests/DOMDocument_saveHTML_variant2.phpt [new file with mode: 0644]

index 45a07f2dc2e99f8ebca36ad3831e9483f3491dc2..6499b55f64d901bb6c9271fe7834391efdaf405a 100644 (file)
@@ -2318,12 +2318,17 @@ PHP_FUNCTION(dom_document_save_html)
                        RETURN_FALSE;
                }
                
-               htmlNodeDumpFormatOutput(buf, docp, node, 0, format);
-               mem = (xmlChar*) xmlBufferContent(buf);
-               if (!mem) {
-                       RETVAL_FALSE;
+               size = htmlNodeDump(buf, docp, node);
+               if (size >= 0) {
+                       mem = (xmlChar*) xmlBufferContent(buf);
+                       if (!mem) {
+                               RETVAL_FALSE;
+                       } else {
+                               RETVAL_STRINGL((const char*) mem, size, 1);
+                       }
                } else {
-                       RETVAL_STRING(mem, 1);
+                       php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error dumping HTML node");
+                       RETVAL_FALSE;
                }
                xmlBufferFree(buf);
        } else {
@@ -2335,7 +2340,7 @@ PHP_FUNCTION(dom_document_save_html)
                if (!size) {
                        RETVAL_FALSE;
                } else {
-                       RETVAL_STRINGL(mem, size, 1);
+                       RETVAL_STRINGL((const char*) mem, size, 1);
                }
                if (mem)
                        xmlFree(mem);
diff --git a/ext/dom/tests/DOMDocument_saveHTML_variant2.phpt b/ext/dom/tests/DOMDocument_saveHTML_variant2.phpt
new file mode 100644 (file)
index 0000000..54ccda1
--- /dev/null
@@ -0,0 +1,26 @@
+--TEST--
+DOMDocument::saveHTML() vs DOMDocumet::saveXML() 
+--SKIPIF--
+<?php
+require_once dirname(__FILE__) .'/skipif.inc';
+?>
+--FILE--
+<?php
+$d = new DOMDocument();
+$str = <<<EOD
+<html>
+<head>
+</head>
+<body>
+<p>Hi.<br/>there</p>
+</body>
+</html>
+EOD;
+$d->loadHTML($str);
+$e = $d->getElementsByTagName("p");
+$e = $e->item(0);
+echo $d->saveXml($e),"\n";
+echo $d->saveHtml($e),"\n";
+--EXPECTF--
+<p>Hi.<br/>there</p>
+<p>Hi.<br>there</p>