diff options
author | Michael Weimann <mail@michael-weimann.eu> | 2018-09-02 14:17:17 +0200 |
---|---|---|
committer | Roeland Jago Douma <roeland@famdouma.nl> | 2018-09-05 20:50:21 +0200 |
commit | 38ea5d14b38d86fe09acf0df34857c9eba6e1c6f (patch) | |
tree | a598a2f6c5ecfacefcdf0c4fc9ae640925558cd7 /apps/theming/lib/Controller/ThemingController.php | |
parent | 0899f2cbc43b05005dc045db001c41e199192f67 (diff) | |
download | nextcloud-server-38ea5d14b38d86fe09acf0df34857c9eba6e1c6f.tar.gz nextcloud-server-38ea5d14b38d86fe09acf0df34857c9eba6e1c6f.zip |
Disables SVG favicon uploads when imagemagick is missing.
Signed-off-by: Michael Weimann <mail@michael-weimann.eu>
Diffstat (limited to 'apps/theming/lib/Controller/ThemingController.php')
-rw-r--r-- | apps/theming/lib/Controller/ThemingController.php | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/apps/theming/lib/Controller/ThemingController.php b/apps/theming/lib/Controller/ThemingController.php index 44f1ea51c06..a1fa5e57836 100644 --- a/apps/theming/lib/Controller/ThemingController.php +++ b/apps/theming/lib/Controller/ThemingController.php @@ -265,7 +265,7 @@ class ThemingController extends Controller { $this->imageManager->delete($key); $target = $folder->newFile($key); - $supportedFormats = ['image/jpeg', 'image/png', 'image/gif', 'image/svg+xml', 'image/svg']; + $supportedFormats = $this->getSupportedUploadImageFormats($key); $detectedMimeType = mime_content_type($image['tmp_name']); if (!in_array($image['type'], $supportedFormats) || !in_array($detectedMimeType, $supportedFormats)) { return new DataResponse( @@ -319,6 +319,24 @@ class ThemingController extends Controller { } /** + * Returns a list of supported mime types for image uploads. + * "favicon" images are only allowed to be SVG when imagemagick with SVG support is available. + * + * @param string $key The image key, e.g. "favicon" + * @return array + */ + private function getSupportedUploadImageFormats(string $key): array { + $supportedFormats = ['image/jpeg', 'image/png', 'image/gif',]; + + if ($key !== 'favicon' || $this->imageManager->shouldReplaceIcons() === true) { + $supportedFormats[] = 'image/svg+xml'; + $supportedFormats[] = 'image/svg'; + } + + return $supportedFormats; + } + + /** * Revert setting to default value * * @param string $setting setting which should be reverted |