mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
FIX Disable libxml_disable_entity_loader() calls in PHP 8
This commit is contained in:
parent
fb9e6e51a6
commit
bad0662291
@ -296,12 +296,17 @@ class Convert
|
|||||||
* @param string $val
|
* @param string $val
|
||||||
* @param boolean $disableDoctypes Disables the use of DOCTYPE, and will trigger an error if encountered.
|
* @param boolean $disableDoctypes Disables the use of DOCTYPE, and will trigger an error if encountered.
|
||||||
* false by default.
|
* false by default.
|
||||||
* @param boolean $disableExternals Disables the loading of external entities. false by default.
|
* @param boolean $disableExternals Disables the loading of external entities. false by default. No-op in PHP 8.
|
||||||
* @return array
|
* @return array
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public static function xml2array($val, $disableDoctypes = false, $disableExternals = false)
|
public static function xml2array($val, $disableDoctypes = false, $disableExternals = false)
|
||||||
{
|
{
|
||||||
|
// PHP 8 deprecates libxml_disable_entity_loader() as it is no longer needed
|
||||||
|
if (\PHP_VERSION_ID >= 80000) {
|
||||||
|
$disableExternals = false;
|
||||||
|
}
|
||||||
|
|
||||||
// Check doctype
|
// Check doctype
|
||||||
if ($disableDoctypes && preg_match('/\<\!DOCTYPE.+]\>/', $val)) {
|
if ($disableDoctypes && preg_match('/\<\!DOCTYPE.+]\>/', $val)) {
|
||||||
throw new InvalidArgumentException('XML Doctype parsing disabled');
|
throw new InvalidArgumentException('XML Doctype parsing disabled');
|
||||||
|
Loading…
Reference in New Issue
Block a user