php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #76777 "public id" parameter of libxml_set_external_entity_loader callback undefined
Submitted: 2018-08-21 19:13 UTC Modified: 2018-08-22 10:57 UTC
From: vhu at iki dot fi Assigned: cmb (profile)
Status: Closed Package: DOM XML related
PHP Version: 7.0.31 OS:
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: vhu at iki dot fi
New email:
PHP Version: OS:

 

 [2018-08-21 19:13 UTC] vhu at iki dot fi
Description:
------------
First parameter of the libxml_set_external_entity_loader() callback is undefined if argument passed to it is null. 

Test script:
---------------
<?php
ini_set('error_reporting',PHP_INT_MAX-1);
$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);
var_dump($dom->schemaValidateSource($xsd));

Expected result:
----------------
NULL
string(15) "nonexistent.xsd"
array(4) {
  ["directory"]=>
  NULL
  ["intSubName"]=>
  NULL
  ["extSubURI"]=>
  NULL
  ["extSubSystem"]=>
  NULL
}

Actual result:
--------------
Notice: Undefined variable: p in /home/huge/test.php on line 17
NULL
string(15) "nonexistent.xsd"
array(4) {
  ["directory"]=>
  NULL
  ["intSubName"]=>
  NULL
  ["extSubURI"]=>
  NULL
  ["extSubSystem"]=>
  NULL
}

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2018-08-21 20:04 UTC] vhu at iki dot fi
Looks like this broke with 7.0: https://3v4l.org/9endu

There is a PR for this: https://github.com/php/php-src/pull/3455 but bugs.php.net throws internal error 500 when trying to link it here.
 [2018-08-21 21:21 UTC] cmb@php.net
> […] but bugs.php.net throws internal error 500 when trying to
> link it here.

Known issue: <https://bugs.php.net/76079>.  Unfortunately, still
unresolved.
 [2018-08-21 21:25 UTC] cmb@php.net
-Status: Open +Status: Verified
 [2018-08-22 10:56 UTC] cmb@php.net
Automatic comment on behalf of vhu@iki.fi
Revision: http://git.php.net/?p=php-src.git;a=commit;h=cf2fc66b0289dc7a34a0d9c0e67bccb8e97472bd
Log: Fixed bug #76777 and added test
 [2018-08-22 10:56 UTC] cmb@php.net
-Status: Verified +Status: Closed
 [2018-08-22 10:57 UTC] cmb@php.net
-Assigned To: +Assigned To: cmb
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Dec 03 17:01:29 2024 UTC