- Hopefully finally fixed the mess in rev 307562 and rev 307563.

This commit is contained in:
Gustavo André dos Santos Lopes 2011-01-19 00:22:06 +00:00
parent 95388b7cda
commit b9b1fb1827
2 changed files with 37 additions and 6 deletions

View 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);

View File

@ -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>