Skip to content

Commit cf2fc66

Browse files
Ville Hukkamakicmb69
authored andcommitted
Fixed bug #76777 and added test
Set undefined values to null rather than undefined.
1 parent 4c542e6 commit cf2fc66

File tree

3 files changed

+49
-2
lines changed

3 files changed

+49
-2
lines changed

NEWS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ PHP NEWS
1717
. Fixed bug #74484 (MessageFormatter::formatMessage memory corruption with
1818
11+ named placeholders). (Anatol)
1919

20+
- libxml:
21+
. Fixed bug #76777 ("public id" parameter of libxml_set_external_entity_loader
22+
callback undefined). (Ville Hukkamäki)
23+
2024
- mbstring:
2125
. Fixed bug #76704 (mb_detect_order return value varies based on argument
2226
type). (cmb)

ext/libxml/libxml.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -591,12 +591,12 @@ static xmlParserInputPtr _php_libxml_external_entity_loader(const char *URL,
591591
if (ID != NULL) {
592592
ZVAL_STRING(&params[0], ID);
593593
} else {
594-
ZVAL_UNDEF(&params[0]);
594+
ZVAL_NULL(&params[0]);
595595
}
596596
if (URL != NULL) {
597597
ZVAL_STRING(&params[1], URL);
598598
} else {
599-
ZVAL_UNDEF(&params[1]);
599+
ZVAL_NULL(&params[1]);
600600
}
601601
ctxzv = &params[2];
602602
array_init_size(ctxzv, 4);

ext/libxml/tests/bug76777.phpt

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
--TEST--
2+
Bug #76777 (first parameter of libxml_set_external_entity_loader callback undefined)
3+
--SKIPIF--
4+
<?php
5+
if (!extension_loaded('libxml')) die('skip');
6+
if (getenv("SKIP_ONLINE_TESTS")) die('skip online test');
7+
?>
8+
--FILE--
9+
<?php
10+
$xml=<<<EOF
11+
<?xml version="1.0"?>
12+
<test/>
13+
EOF;
14+
15+
$xsd=<<<EOF
16+
<?xml version="1.0"?>
17+
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
18+
<xs:include schemaLocation="nonexistent.xsd"/>
19+
<xs:element name="test"/>
20+
</xs:schema>
21+
EOF;
22+
23+
libxml_set_external_entity_loader(function($p,$s,$c) {
24+
var_dump($p,$s,$c);
25+
die();
26+
});
27+
28+
$dom=new DOMDocument($xml);
29+
$dom->schemaValidateSource($xsd);
30+
?>
31+
--EXPECTF--
32+
NULL
33+
string(15) "nonexistent.xsd"
34+
array(4) {
35+
["directory"]=>
36+
NULL
37+
["intSubName"]=>
38+
NULL
39+
["extSubURI"]=>
40+
NULL
41+
["extSubSystem"]=>
42+
NULL
43+
}

0 commit comments

Comments
 (0)