diff options
author | Gustavo André dos Santos Lopes <cataphract@php.net> | 2011-01-19 00:22:06 +0000 |
---|---|---|
committer | Gustavo André dos Santos Lopes <cataphract@php.net> | 2011-01-19 00:22:06 +0000 |
commit | b9b1fb18278bc3a415dc5a73624b8b0e60cf5fec (patch) | |
tree | 09952b319414f299be9ac0c08fb30b9798dae137 | |
parent | 95388b7cdab48a167e06188467597d554489f686 (diff) | |
download | php-git-b9b1fb18278bc3a415dc5a73624b8b0e60cf5fec.tar.gz |
- Hopefully finally fixed the mess in rev 307562 and rev 307563.
-rw-r--r-- | ext/dom/document.c | 17 | ||||
-rw-r--r-- | ext/dom/tests/DOMDocument_saveHTML_variant2.phpt | 26 |
2 files changed, 37 insertions, 6 deletions
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-- +<?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> |