diff --git a/ext/dom/document.c b/ext/dom/document.c index 22bb90d5d88db..0e15e7a110652 100644 --- a/ext/dom/document.c +++ b/ext/dom/document.c @@ -2024,7 +2024,6 @@ static void dom_load_html(INTERNAL_FUNCTION_PARAMETERS, int mode) /* {{{ */ } ctxt = htmlCreateFileParserCtxt(source, NULL); } else { - source_len = xmlStrlen((xmlChar *) source); if (ZEND_SIZE_T_INT_OVFL(source_len)) { php_error_docref(NULL, E_WARNING, "Input string is too long"); RETURN_FALSE; diff --git a/ext/dom/tests/bug80268.phpt b/ext/dom/tests/bug80268.phpt new file mode 100644 index 0000000000000..0fe50b85e8611 --- /dev/null +++ b/ext/dom/tests/bug80268.phpt @@ -0,0 +1,24 @@ +--TEST-- +Bug #80268 (loadHTML() truncates at NUL bytes) +--SKIPIF-- + +--FILE-- +loadHTML("

foo\0bar

"); +$html = $doc->saveHTML(); +var_dump(strpos($html, '

foo

') !== false); + +file_put_contents(__DIR__ . '/80268.html', "

foo\0bar

"); +$doc = new DOMDocument; +$doc->loadHTMLFile(__DIR__ . '/80268.html'); +$html = $doc->saveHTML(); +var_dump(strpos($html, '

foo

') !== false); +?> +--CLEAN-- + +--EXPECT-- +bool(true) +bool(true)