]> granicus.if.org Git - php/commitdiff
Don't throw warning if exception thrown during dom validation
authorNikita Popov <nikita.ppv@gmail.com>
Thu, 25 Jun 2020 13:24:01 +0000 (15:24 +0200)
committerNikita Popov <nikita.ppv@gmail.com>
Thu, 25 Jun 2020 13:24:35 +0000 (15:24 +0200)
ext/dom/document.c
ext/libxml/libxml.c
ext/libxml/tests/libxml_set_external_entity_loader_error1.phpt

index 89f635877591bedab5b1a27384b3e7347a93bcb4..aa1d99ebd2c22ec994f756b4750550e1faec20e9 100644 (file)
@@ -1681,7 +1681,9 @@ static void _dom_document_schema_validate(INTERNAL_FUNCTION_PARAMETERS, int type
        sptr = xmlSchemaParse(parser);
        xmlSchemaFreeParserCtxt(parser);
        if (!sptr) {
-               php_error_docref(NULL, E_WARNING, "Invalid Schema");
+               if (!EG(exception)) {
+                       php_error_docref(NULL, E_WARNING, "Invalid Schema");
+               }
                RETURN_FALSE;
        }
 
index 85eaf7a0264ac3e4efaedea0c5891178acb3606c..d77f6aa2fdeaf0eaf40f3bf69e3e82bf3f61d77b 100644 (file)
@@ -485,7 +485,6 @@ static void php_libxml_internal_error_handler(int error_type, void *ctx, const c
        char *buf;
        int len, len_iter, output = 0;
 
-
        len = vspprintf(&buf, 0, *msg, ap);
        len_iter = len;
 
@@ -502,7 +501,8 @@ static void php_libxml_internal_error_handler(int error_type, void *ctx, const c
        if (output == 1) {
                if (LIBXML(error_list)) {
                        _php_list_set_error_structure(NULL, ZSTR_VAL(LIBXML(error_buffer).s));
-               } else {
+               } else if (!EG(exception)) {
+                       /* Don't throw additional notices/warnings if an exception has already been thrown. */
                        switch (error_type) {
                                case PHP_LIBXML_CTX_ERROR:
                                        php_libxml_ctx_error_level(E_WARNING, ctx, ZSTR_VAL(LIBXML(error_buffer).s));
index ea0764f9808b053913ce6aaf28753fa872685c46..70aa9ceaa474b91dae4af919e2145fa1c482ddf6 100644 (file)
@@ -20,9 +20,7 @@ try {
 }
 
 echo "Done.\n";
---EXPECTF--
+--EXPECT--
 bool(true)
-
-Warning: DOMDocument::validate(): Could not load the external subset "http://example.com/foobar" in %s on line %d
 Exception: Too few arguments to function {closure}(), 3 passed and exactly 4 expected
 Done.