Skip to content

Commit

Permalink
adding version check around libxml_disable_entity_loader (#84)
Browse files Browse the repository at this point in the history
* adding version check around libxml_disable_entity_loader

* adding back psr0 fixer
  • Loading branch information
jaydiablo authored Feb 18, 2021
1 parent 1e8cfe6 commit 1c559c7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
2 changes: 0 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,6 @@ jobs:
- name: PHPStan
run: composer phpstan
- name: Code Style Check
env:
PHP_CS_FIXER_IGNORE_ENV: true
run: composer style-check -- --format=checkstyle | cs2pr
- name: Test
run: composer test-with-coverage
Expand Down
12 changes: 9 additions & 3 deletions src/Zend/Xml/Security.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,9 @@ public static function scan($xml, DOMDocument $dom = null)
}

if (!self::isPhpFpm()) {
$loadEntities = libxml_disable_entity_loader(true);
if (version_compare(PHP_VERSION, '8.0.0', 'lt')) {
$loadEntities = libxml_disable_entity_loader(true);
}
$useInternalXmlErrors = libxml_use_internal_errors(true);
}

Expand All @@ -98,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 (version_compare(PHP_VERSION, '8.0.0', 'lt')) {
libxml_disable_entity_loader($loadEntities);
}
libxml_use_internal_errors($useInternalXmlErrors);
}
return false;
Expand All @@ -120,7 +124,9 @@ public static function scan($xml, DOMDocument $dom = null)

// Entity load to previous setting
if (!self::isPhpFpm()) {
libxml_disable_entity_loader($loadEntities);
if (version_compare(PHP_VERSION, '8.0.0', 'lt')) {
libxml_disable_entity_loader($loadEntities);
}
libxml_use_internal_errors($useInternalXmlErrors);
}

Expand Down

0 comments on commit 1c559c7

Please sign in to comment.