Skip to content

Commit

Permalink
Fixed bug #76777 and added test
Browse files Browse the repository at this point in the history
Set undefined values to null rather than undefined.
  • Loading branch information
Ville Hukkamaki authored and cmb69 committed Aug 22, 2018
1 parent 4c542e6 commit cf2fc66
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 2 deletions.
4 changes: 4 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ PHP NEWS
. Fixed bug #74484 (MessageFormatter::formatMessage memory corruption with
11+ named placeholders). (Anatol)

- libxml:
. Fixed bug #76777 ("public id" parameter of libxml_set_external_entity_loader
callback undefined). (Ville Hukkamäki)

- mbstring:
. Fixed bug #76704 (mb_detect_order return value varies based on argument
type). (cmb)
Expand Down
4 changes: 2 additions & 2 deletions ext/libxml/libxml.c
Original file line number Diff line number Diff line change
Expand Up @@ -591,12 +591,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);
Expand Down
43 changes: 43 additions & 0 deletions ext/libxml/tests/bug76777.phpt
Original file line number Diff line number Diff line change
@@ -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
}

0 comments on commit cf2fc66

Please sign in to comment.