Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: Ivan Kancijan <[email protected]>
  • Loading branch information
iruzevic and kancijan authored Jun 14, 2024
1 parent 8c6070f commit 5d95d45
Showing 1 changed file with 14 additions and 13 deletions.
27 changes: 14 additions & 13 deletions src/Media/AbstractMedia.php
Original file line number Diff line number Diff line change
Expand Up @@ -148,22 +148,23 @@ public function enableSvgMediaLibraryPreview($response, $attachment)
*/
public function validateSvgOnUpload($response)
{
if ($response['type'] === 'image/svg+xml' && \class_exists('SimpleXMLElement')) {
$path = $response['tmp_name'];
if ($response['type'] !== 'image/svg+xml' && !\class_exists('SimpleXMLElement')) {
return $response;
}

$svgContent = \file($path);
$svgContent = \implode(' ', $svgContent);
$path = $response['tmp_name'] ?? '';

if (\file_exists($path)) {
if (!Helpers::isValidXml($svgContent)) {
return [
'size' => $response,
'name' => $response['name'],
];
}
}
$svgContent = \file($path);
$svgContent = \implode(' ', $svgContent);

if (!\file_exists($path) || Helpers::isValidXml($svgContent)) {
return $response;
}
return $response;

return [
'size' => $response,
'name' => $response['name'],
];
}

/**
Expand Down

0 comments on commit 5d95d45

Please sign in to comment.