From: Gustavo André dos Santos Lopes Date: Wed, 19 Jan 2011 00:22:06 +0000 (+0000) Subject: - Hopefully finally fixed the mess in rev 307562 and rev 307563. X-Git-Tag: php-5.4.0alpha1~191^2~354 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=b9b1fb18278bc3a415dc5a73624b8b0e60cf5fec;p=php - Hopefully finally fixed the mess in rev 307562 and rev 307563. --- diff --git a/ext/dom/document.c b/ext/dom/document.c index 45a07f2dc2..6499b55f64 100644 --- a/ext/dom/document.c +++ b/ext/dom/document.c @@ -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 index 0000000000..54ccda1fa5 --- /dev/null +++ b/ext/dom/tests/DOMDocument_saveHTML_variant2.phpt @@ -0,0 +1,26 @@ +--TEST-- +DOMDocument::saveHTML() vs DOMDocumet::saveXML() +--SKIPIF-- + +--FILE-- + + + + +

Hi.
there

+ + +EOD; +$d->loadHTML($str); +$e = $d->getElementsByTagName("p"); +$e = $e->item(0); +echo $d->saveXml($e),"\n"; +echo $d->saveHtml($e),"\n"; +--EXPECTF-- +

Hi.
there

+

Hi.
there