summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--NEWS4
-rw-r--r--ext/libxml/libxml.c4
-rw-r--r--ext/libxml/tests/bug76777.phpt43
3 files changed, 49 insertions, 2 deletions
diff --git a/NEWS b/NEWS
index 1bcfd3c717..3119eb5ce2 100644
--- a/NEWS
+++ b/NEWS
@@ -12,6 +12,10 @@ PHP NEWS
. Fixed bug #76285 (DOMDocument::formatOutput attribute sometimes ignored).
(Andrew Nester, Laruence, Anatol)
+- libxml:
+ . Fixed bug #76777 ("public id" parameter of libxml_set_external_entity_loader
+ callback undefined). (Ville Hukkamäki)
+
- Opcache:
. Fixed bug #76747 (Opcache treats path containing "test.pharma.tld" as a phar
file). (Laruence)
diff --git a/ext/libxml/libxml.c b/ext/libxml/libxml.c
index 0309500f11..3c1c8c3c84 100644
--- a/ext/libxml/libxml.c
+++ b/ext/libxml/libxml.c
@@ -589,12 +589,12 @@ static xmlParserInputPtr _php_libxml_external_entity_loader(const char *URL,
if (ID != NULL) {
ZVAL_STRING(&params[0], ID);
} else {
- ZVAL_UNDEF(&params[0]);
+ ZVAL_NULL(&params[0]);
}
if (URL != NULL) {
ZVAL_STRING(&params[1], URL);
} else {
- ZVAL_UNDEF(&params[1]);
+ ZVAL_NULL(&params[1]);
}
ctxzv = &params[2];
array_init_size(ctxzv, 4);
diff --git a/ext/libxml/tests/bug76777.phpt b/ext/libxml/tests/bug76777.phpt
new file mode 100644
index 0000000000..ba9fd698e0
--- /dev/null
+++ b/ext/libxml/tests/bug76777.phpt
@@ -0,0 +1,43 @@
+--TEST--
+Bug #76777 (first parameter of libxml_set_external_entity_loader callback undefined)
+--SKIPIF--
+<?php
+if (!extension_loaded('libxml')) die('skip');
+if (getenv("SKIP_ONLINE_TESTS")) die('skip online test');
+?>
+--FILE--
+<?php
+$xml=<<<EOF
+<?xml version="1.0"?>
+<test/>
+EOF;
+
+$xsd=<<<EOF
+<?xml version="1.0"?>
+<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
+ <xs:include schemaLocation="nonexistent.xsd"/>
+ <xs:element name="test"/>
+</xs:schema>
+EOF;
+
+libxml_set_external_entity_loader(function($p,$s,$c) {
+ var_dump($p,$s,$c);
+ die();
+});
+
+$dom=new DOMDocument($xml);
+$dom->schemaValidateSource($xsd);
+?>
+--EXPECTF--
+NULL
+string(15) "nonexistent.xsd"
+array(4) {
+ ["directory"]=>
+ NULL
+ ["intSubName"]=>
+ NULL
+ ["extSubURI"]=>
+ NULL
+ ["extSubSystem"]=>
+ NULL
+}