|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2012-07-16 08:56 UTC] 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)
Patchesmove-entity_loader_disabled-check (last revision 2018-10-15 10:50 UTC by cmb@php.net)Pull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Oct 25 04:00:01 2025 UTC |
> and if you don't give valid path, you get an error and false. of course. But this bug is about `simplexml_load_file` failing on *any* valid path if `libxml_disable_entity_loader(true)` has been called. Here's a test script. IMHO, both assert()s should pass: <?php file_put_contents('/tmp/test.xml', '<doc><foo>bar</foo></doc>'); libxml_disable_entity_loader(false); assert(simplexml_load_file('/tmp/test.xml')->foo == 'bar'); libxml_disable_entity_loader(true); assert(simplexml_load_file('/tmp/test.xml')->foo == 'bar'); unlink('/tmp/test.xml');