Edit report at https://bugs.php.net/bug.php?id=62577&edit=1
ID: 62577
Comment by: sjon at hortensius dot net
Reported by: ivan dot enderlin at hoa-project dot net
Summary: simplexml_load_file does not file if
libxml_disable_entity_loader(true)
Status: Assigned
Type: Bug
Package: SimpleXML related
Operating System: All
PHP Version: master-Git-2012-07-16 (Git)
Assigned To: rrichards
Block user comment: N
Private report: N
New Comment:
I can confirm this issue; it is very annoying and unexpected. Can't the code,
as
a work-around use file-get-contents + simplexml_load_string internally?
This issue is also related to bug #64938 imo
Previous Comments:
------------------------------------------------------------------------
[2013-05-29 07:20:39] Sjon at hortensius dot net
I can confirm this issue; it is very annoying and unexpected. Can't the code,
as
a work-around use file-get-contents + simplexml_load_string internally?
This issue is also related to #22215 imo
------------------------------------------------------------------------
[2012-11-15 11:03:10] [email protected]
hi Rob!
What would be the best/cleanest fix for this issue? It affects quite a lot of
apps
out there.
Thanks!
------------------------------------------------------------------------
[2012-07-16 09:25:29] ivan dot enderlin at hoa-project dot net
I think it's not a normal behavior.
------------------------------------------------------------------------
[2012-07-16 09:22:31] [email protected]
http://lxr.php.net/xref/PHP_5_4/ext/libxml/libxml.c#1058
libxml_disable_entity_loader(true) registers a NULL function
(http://lxr.php.net/xref/PHP_5_4/ext/libxml/libxml.c#372) as callback for URI
input file handling in libxml.
So you cant open any file with libxml after having called this function.
Is that the correct behavior ? I have no clue to answer that
------------------------------------------------------------------------
[2012-07-16 08:56:06] ivan dot enderlin at hoa-project dot net
Description:
------------
The function simplexml_load_file() failed to open any file (existing or not) if
libxml_disable_entity_loader(true) has been called.
I have tried with simplexml_load_string(), it works; same with new
SimpleXMLElement() etc. The bug is restricted to the simplexml_load_file()
function.
Test script:
---------------
<?php
libxml_use_internal_errors(true);
libxml_disable_entity_loader(true);
$xml = simplexml_load_file('foo');
print_r(libxml_get_errors());
var_dump($xml);
Expected result:
----------------
Array
(
)
â¦
Actual result:
--------------
Array
(
[0] => LibXMLError Object
(
[level] => 1
[code] => 1549
[column] => 0
[message] => failed to load external entity "foo"
[file] =>
[line] => 0
)
)
bool(false)
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=62577&edit=1