php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #74004 LIBXML_NOWARNING flag ingnored on loadHTML*
Submitted: 2017-01-26 21:35 UTC Modified: 2017-03-02 11:38 UTC
From: work at timothytown dot com Assigned: nikic
Status: Closed Package: DOM XML related
PHP Version: 7.1.1 OS: all
Private report: No CVE-ID:
 [2017-01-26 21:35 UTC] work at timothytown dot com
Description:
------------
The source in the PHP dom extension causes the LIBXML_NOWARNING flag to be ignored when loading html through DOMDocument.

Problem is in ext/dom/document.c of PHP source, in the dom_load_html method. 
Calling htmlCtxtUseOptions with HTML_PARSE_NOWARNING causes the warning handlers to be unregistered (set to NULL). But the PHP code then proceeds to install its own handlers unconditionally, rendering the flag useless. 

see stackoverflow http://stackoverflow.com/questions/41860683/libxml-htmlparsedocument-ignoring-htmlparseoption-flags

Test script:
---------------
$doc=new DOMDocument();
$doc->loadHTML("<tagthatthrowswarning>HI</tagthatthrowswarning>", LIBXML_NOWARNING);
echo $doc->saveHTML();

Expected result:
----------------
expected output 
no warnings output.


Actual result:
--------------
E_WARNING : type 2 -- DOMDocument::loadHTML(): Tag tagthatthrowswarning invalid in Entity, line: 1 -- at line 4


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2017-01-27 19:03 UTC] cmb@php.net
-Status: Open +Status: Verified
 [2017-01-27 19:03 UTC] cmb@php.net
Confirmed: <https://3v4l.org/vZR37>.
 [2017-02-03 06:14 UTC] krakjoe@php.net
Automatic comment on behalf of info@timothytown.com
Revision: http://git.php.net/?p=php-src.git;a=commit;h=4df993d89da9b78513a75611421e15e100829695
Log: Fixed bug #74004 LIBXML_NOWARNING (etc) ignored by DOMDocument::loadHTML
 [2017-02-03 06:14 UTC] krakjoe@php.net
-Status: Verified +Status: Closed
 [2017-02-03 19:06 UTC] krakjoe@php.net
-Status: Closed +Status: Re-Opened
 [2017-03-02 11:38 UTC] nikic@php.net
-Status: Re-Opened +Status: Closed -Assigned To: +Assigned To: nikic
 
PHP Copyright © 2001-2017 The PHP Group
All rights reserved.
Last updated: Tue Apr 25 14:01:39 2017 UTC