Merge pull request #25039 from nextcloud/fix/libxml-use-internal-errors-deprecated

Only use libxml_disable_entity_loader on php older than 8
This commit is contained in:
Roeland Jago Douma 2021-01-11 16:14:38 +01:00 committed by GitHub
commit fdd111924f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 3 deletions

View File

@ -32,6 +32,8 @@
namespace OC\App;
use OCP\ICache;
use function libxml_disable_entity_loader;
use function simplexml_load_file;
class InfoParser {
/** @var \OCP\ICache|null */
@ -61,10 +63,14 @@ class InfoParser {
}
libxml_use_internal_errors(true);
$loadEntities = libxml_disable_entity_loader(false);
$xml = simplexml_load_file($file);
if ((PHP_VERSION_ID < 80000)) {
$loadEntities = libxml_disable_entity_loader(false);
$xml = simplexml_load_file($file);
libxml_disable_entity_loader($loadEntities);
} else {
$xml = simplexml_load_file($file);
}
libxml_disable_entity_loader($loadEntities);
if ($xml === false) {
libxml_clear_errors();
return null;