diff --git a/library/Zend/Xml/Security.php b/library/Zend/Xml/Security.php index 11cd3ba638..4462b7f177 100644 --- a/library/Zend/Xml/Security.php +++ b/library/Zend/Xml/Security.php @@ -93,12 +93,13 @@ public static function scan($xml, DOMDocument $dom = null) $result = $dom->loadXml($xml, LIBXML_NONET); restore_error_handler(); + // Entity load to previous setting + if (!self::isPhpFpm()) { + libxml_disable_entity_loader($loadEntities); + libxml_use_internal_errors($useInternalXmlErrors); + } + if (!$result) { - // Entity load to previous setting - if (!self::isPhpFpm()) { - libxml_disable_entity_loader($loadEntities); - libxml_use_internal_errors($useInternalXmlErrors); - } return false; } @@ -114,12 +115,6 @@ public static function scan($xml, DOMDocument $dom = null) } } - // Entity load to previous setting - if (!self::isPhpFpm()) { - libxml_disable_entity_loader($loadEntities); - libxml_use_internal_errors($useInternalXmlErrors); - } - if (isset($simpleXml)) { $result = simplexml_import_dom($dom); if (!$result instanceof SimpleXMLElement) {