Skip to content

Commit

Permalink
Merge pull request #2 from magento-trigger/zf1-update
Browse files Browse the repository at this point in the history
php 8 compatibility in Zend_Xml_Security class
  • Loading branch information
fascinosum authored Sep 15, 2021
2 parents 6ad8150 + c5206c6 commit c8ab365
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions library/Zend/Xml/Security.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,10 @@ public static function scan($xml, DOMDocument $dom = null)
}

if (!self::isPhpFpm()) {
$loadEntities = libxml_disable_entity_loader(true);
if (LIBXML_VERSION < 20900) {
// this function no longer has an effect in PHP 8.0, but it's required in earlier versions
$loadEntities = libxml_disable_entity_loader(true);
}
$useInternalXmlErrors = libxml_use_internal_errors(true);
}

Expand All @@ -97,7 +100,9 @@ public static function scan($xml, DOMDocument $dom = null)
if (!$result) {
// Entity load to previous setting
if (!self::isPhpFpm()) {
libxml_disable_entity_loader($loadEntities);
if (isset($loadEntities)) {
libxml_disable_entity_loader($loadEntities);
}
libxml_use_internal_errors($useInternalXmlErrors);
}
return false;
Expand All @@ -117,7 +122,9 @@ public static function scan($xml, DOMDocument $dom = null)

// Entity load to previous setting
if (!self::isPhpFpm()) {
libxml_disable_entity_loader($loadEntities);
if (isset($loadEntities)) {
libxml_disable_entity_loader($loadEntities);
}
libxml_use_internal_errors($useInternalXmlErrors);
}

Expand Down Expand Up @@ -167,10 +174,10 @@ public static function scanFile($file, DOMDocument $dom = null)
public static function isPhpFpm()
{
$isVulnerableVersion = (
version_compare(PHP_VERSION, '5.5.22', 'lt')
version_compare(PHP_VERSION, '5.5.22', '<')
|| (
version_compare(PHP_VERSION, '5.6', 'gte')
&& version_compare(PHP_VERSION, '5.6.6', 'lt')
version_compare(PHP_VERSION, '5.6', '>=')
&& version_compare(PHP_VERSION, '5.6.6', '<')
)
);

Expand Down

0 comments on commit c8ab365

Please sign in to comment.