Skip to content
This repository has been archived by the owner on Oct 18, 2023. It is now read-only.

Commit

Permalink
Merge pull request from GHSA-59cf-m7v5-wh5w
Browse files Browse the repository at this point in the history
[BUGFIX] Scan files with extension svg and other mime-types
  • Loading branch information
NeoBlack authored May 12, 2020
2 parents 763a245 + 63eea9e commit b002dbf
Show file tree
Hide file tree
Showing 23 changed files with 120,808 additions and 1 deletion.
5 changes: 4 additions & 1 deletion Classes/Service/SvgSanitizerService.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
*/
class SvgSanitizerService
{
protected $possibleMimeTypes = ['image/svg', 'image/svg+xml', 'application/svg', 'application/svg+xml'];

/**
* @param string $fileNameAndPath
* @return bool
Expand All @@ -39,7 +41,8 @@ class SvgSanitizerService
public function isSvgFile($fileNameAndPath)
{
$fileInfo = GeneralUtility::makeInstance(FileInfo::class, $fileNameAndPath);
return \in_array($fileInfo->getMimeType(), ['image/svg+xml', 'application/svg+xml'], true);
return $fileInfo->getExtension() === 'svg'
|| \in_array(strtolower($fileInfo->getMimeType()), $this->possibleMimeTypes, true);
}

/**
Expand Down
57 changes: 57 additions & 0 deletions Tests/Fixtures/CleanSVG/ariaData.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 10 additions & 0 deletions Tests/Fixtures/CleanSVG/external.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 13 additions & 0 deletions Tests/Fixtures/CleanSVG/hrefOne.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 13 additions & 0 deletions Tests/Fixtures/CleanSVG/hrefTwo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 13 additions & 0 deletions Tests/Fixtures/CleanSVG/svgOne.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions Tests/Fixtures/CleanSVG/use.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
113 changes: 113 additions & 0 deletions Tests/Fixtures/CleanSVG/useDos.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit b002dbf

Please sign in to comment.