From 96c7fec68c61ab50680477e1685214c899423407 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Tim=20D=C3=BCsterhus?= Date: Thu, 5 May 2016 22:10:33 +0200 Subject: [PATCH] Add missing image check in StyleEditor::import() --- .../files/lib/data/style/StyleEditor.class.php | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/wcfsetup/install/files/lib/data/style/StyleEditor.class.php b/wcfsetup/install/files/lib/data/style/StyleEditor.class.php index e4b0f9183f..662484969e 100644 --- a/wcfsetup/install/files/lib/data/style/StyleEditor.class.php +++ b/wcfsetup/install/files/lib/data/style/StyleEditor.class.php @@ -468,7 +468,20 @@ class StyleEditor extends DatabaseObjectEditor implements IEditableCachedObject FileUtil::makeWritable($filename); if (file_exists($filename)) { - $style->update(array('image' => 'stylePreview-'.$style->styleID.$fileExtension)); + try { + if (($imageData = getimagesize($filename)) !== false) { + switch ($imageData[2]) { + case IMG_PNG: + case IMG_JPEG: + case IMG_JPG: + case IMG_GIF: + $style->update(array('image' => 'stylePreview-'.$style->styleID.$fileExtension)); + } + } + } + catch (SystemException $e) { + // broken image + } } } } -- 2.20.1