From 60fa61de5b151f8a1f46165f9aec4984ebd2ad87 Mon Sep 17 00:00:00 2001 From: Jonathan Desrosiers Date: Wed, 14 Apr 2021 23:08:25 +0000 Subject: [PATCH] External libraries: Include upstream GetID3 fix for PHP 8. Props jrf, xknown. git-svn-id: https://develop.svn.wordpress.org/trunk@50714 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/ID3/getid3.lib.php | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/src/wp-includes/ID3/getid3.lib.php b/src/wp-includes/ID3/getid3.lib.php index 3a5983fc26..8514e9781f 100644 --- a/src/wp-includes/ID3/getid3.lib.php +++ b/src/wp-includes/ID3/getid3.lib.php @@ -720,18 +720,14 @@ class getid3_lib */ public static function XML2array($XMLstring) { if (function_exists('simplexml_load_string') && function_exists('libxml_disable_entity_loader')) { - if (PHP_VERSION_ID < 80000) { - // http://websec.io/2012/08/27/Preventing-XEE-in-PHP.html - // https://core.trac.wordpress.org/changeset/29378 - // This function has been deprecated in PHP 8.0 because in libxml 2.9.0, external entity loading is - // disabled by default, so this function is no longer needed to protect against XXE attacks. - $loader = libxml_disable_entity_loader(true); - } + // http://websec.io/2012/08/27/Preventing-XEE-in-PHP.html + // https://core.trac.wordpress.org/changeset/29378 + // This function has been deprecated in PHP 8.0 because in libxml 2.9.0, external entity loading is + // disabled by default, but is still needed when LIBXML_NOENT is used. + $loader = @libxml_disable_entity_loader(true); $XMLobject = simplexml_load_string($XMLstring, 'SimpleXMLElement', LIBXML_NOENT); $return = self::SimpleXMLelement2array($XMLobject); - if (PHP_VERSION_ID < 80000 && isset($loader)) { - libxml_disable_entity_loader($loader); - } + @libxml_disable_entity_loader($loader); return $return; } return false;