mirror of
https://github.com/php/php-src.git
synced 2026-03-24 00:02:20 +01:00
Improve warning when returning null from the resolver set by libxml_set_external_entity_loader
Fixes GH-11952. Closes GH-12022.
This commit is contained in:
4
NEWS
4
NEWS
@@ -7,6 +7,10 @@ PHP NEWS
|
||||
. Introduced Zend guard recursion protection to fix __debugInfo issue.
|
||||
(Jakub Zelenka)
|
||||
|
||||
- DOM:
|
||||
. Fixed GH-11952 (Confusing warning when blocking entity loading via
|
||||
libxml_set_external_entity_loader). (nielsdos)
|
||||
|
||||
- Standard:
|
||||
. Added $before_needle argument to strrchr(). (HypeMC)
|
||||
|
||||
|
||||
@@ -784,10 +784,12 @@ is_string:
|
||||
if (ret == NULL) {
|
||||
if (resource == NULL) {
|
||||
if (ID == NULL) {
|
||||
ID = "NULL";
|
||||
php_libxml_ctx_error(context,
|
||||
"Failed to load external entity because the resolver function returned null\n");
|
||||
} else {
|
||||
php_libxml_ctx_error(context,
|
||||
"Failed to load external entity \"%s\"\n", ID);
|
||||
}
|
||||
php_libxml_ctx_error(context,
|
||||
"Failed to load external entity \"%s\"\n", ID);
|
||||
} else {
|
||||
/* we got the resource in the form of a string; open it */
|
||||
ret = xmlNewInputFromFile(context, resource);
|
||||
|
||||
32
ext/libxml/tests/null_returned_by_resolver.phpt
Normal file
32
ext/libxml/tests/null_returned_by_resolver.phpt
Normal file
@@ -0,0 +1,32 @@
|
||||
--TEST--
|
||||
null returned by resolver function
|
||||
--EXTENSIONS--
|
||||
libxml
|
||||
dom
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
libxml_set_external_entity_loader(function ($public_id, $system_id, $context) {
|
||||
var_dump($public_id, $system_id, $context);
|
||||
return null;
|
||||
});
|
||||
|
||||
$doc = new DOMDocument();
|
||||
$doc->loadHTMLFile("foobar");
|
||||
|
||||
?>
|
||||
--EXPECTF--
|
||||
NULL
|
||||
string(6) "foobar"
|
||||
array(4) {
|
||||
["directory"]=>
|
||||
NULL
|
||||
["intSubName"]=>
|
||||
NULL
|
||||
["extSubURI"]=>
|
||||
NULL
|
||||
["extSubSystem"]=>
|
||||
NULL
|
||||
}
|
||||
|
||||
Warning: DOMDocument::loadHTMLFile(): Failed to load external entity because the resolver function returned null in %s on line %d
|
||||
Reference in New Issue
Block a user