Skip to content

Commit

Permalink
[TASK] Cleanup SvgUtility
Browse files Browse the repository at this point in the history
  • Loading branch information
benjaminkott committed Oct 8, 2024
1 parent 62a32fd commit 2294185
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 14 deletions.
5 changes: 0 additions & 5 deletions Build/phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,6 @@ parameters:
count: 1
path: ../Classes/Utility/ExternalMediaUtility.php

-
message: "#^Call to deprecated function libxml_disable_entity_loader\\(\\)\\.$#"
count: 2
path: ../Classes/Utility/SvgUtility.php

-
message: "#^Variable property access on SimpleXMLElement\\.$#"
count: 2
Expand Down
10 changes: 1 addition & 9 deletions Classes/Utility/SvgUtility.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,7 @@ public static function getInlineSvg(
}

// Disables the functionality to allow external entities to be loaded when parsing the XML, must be kept
$previousValueOfEntityLoader = false;
if (PHP_MAJOR_VERSION < 8) {
$previousValueOfEntityLoader = libxml_disable_entity_loader(true);
}
$svgElement = simplexml_load_string($svgContent);
if (PHP_MAJOR_VERSION < 8) {
libxml_disable_entity_loader($previousValueOfEntityLoader);
}
if (!$svgElement instanceof \SimpleXMLElement) {
return '';
}
Expand All @@ -78,8 +71,7 @@ public static function getInlineSvg(

// remove xml version tag
$domXml = dom_import_simplexml($svgElement);
/** @phpstan-ignore-next-line */
if (!$domXml instanceof \DOMElement || !$domXml->ownerDocument instanceof \DOMDocument) {
if (!$domXml->ownerDocument instanceof \DOMDocument) {
return '';
}

Expand Down

0 comments on commit 2294185

Please sign in to comment.