com php-src: Fixed bug #74004 LIBXML_NOWARNING (etc) ignored by DOMDocument::loadHTML: ext/dom/document .c ext/dom/tests/bug74004.phpt

[email protected] (Joe Watkins)
Newsgroups php.cvs
Message-ID <[email protected]>
Commit:    4df993d89da9b78513a75611421e15e100829695
Author:    somedaysummer <[email protected]>         Fri, 27 Jan 2017 15:20:07 -0500
Committer: Joe Watkins <[email protected]>      Fri, 3 Feb 2017 06:08:42 +0000
Parents:   75ad2b301a047209e7b5a6b5912eb589cfbc773d
Branches:  PHP-7.0 PHP-7.1 master

Link:       http://git.php.net/?p=php-src.git;a=commitdiff;h=4df993d89da9b78513a75611421e15e100829695

Log:
Fixed bug #74004 LIBXML_NOWARNING (etc) ignored by DOMDocument::loadHTML

Bugs:
https://bugs.php.net/74004

Changed paths:
  M  ext/dom/document.c
  A  ext/dom/tests/bug74004.phpt


Diff:
diff --git a/ext/dom/document.c b/ext/dom/document.c
index cab0aa5..a884087 100644
--- a/ext/dom/document.c
+++ b/ext/dom/document.c
@@ -2038,16 +2038,16 @@ static void dom_load_html(INTERNAL_FUNCTION_PARAMETERS, int mode) /* {{{ */
 		RETURN_FALSE;
 	}
 
-	if (options) {
-		htmlCtxtUseOptions(ctxt, (int)options);
-	}
-
+	
 	ctxt->vctxt.error = php_libxml_ctx_error;
 	ctxt->vctxt.warning = php_libxml_ctx_warning;
 	if (ctxt->sax != NULL) {
 		ctxt->sax->error = php_libxml_ctx_error;
 		ctxt->sax->warning = php_libxml_ctx_warning;
 	}
+	if (options) {
+		htmlCtxtUseOptions(ctxt, (int)options);
+	}
 	htmlParseDocument(ctxt);
 	newdoc = ctxt->myDoc;
 	htmlFreeParserCtxt(ctxt);
diff --git a/ext/dom/tests/bug74004.phpt b/ext/dom/tests/bug74004.phpt
new file mode 100644
index 0000000..853dfa5
--- /dev/null
+++ b/ext/dom/tests/bug74004.phpt
@@ -0,0 +1,15 @@
+--TEST--
+Bug #74004 (DOMDocument->loadHTML and ->loadHTMLFile do not heed LIBXML_NOWARNING and LIBXML_NOERROR options)
+--SKIPIF--
+<?php require_once('skipif.inc'); ?>
+--FILE--
+<?php
+
+$doc=new DOMDocument();
+libxml_use_internal_errors(true);
+$doc->loadHTML("<tag-throw-warning></tag-throw-warning>",LIBXML_NOWARNING|LIBXML_NOERROR);
+print count(libxml_get_errors());
+
+?>
+--EXPECT--
+0
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.