Add missing image check in StyleEditor::import()
authorTim Düsterhus <duesterhus@woltlab.com>
Thu, 5 May 2016 20:10:33 +0000 (22:10 +0200)
committerTim Düsterhus <duesterhus@woltlab.com>
Fri, 6 May 2016 12:02:38 +0000 (14:02 +0200)
wcfsetup/install/files/lib/data/style/StyleEditor.class.php

index e4b0f9183f72cdd6cd0aa618e60298758e335792..662484969effaf5379200410d1efdcccd1b2b8a8 100644 (file)
@@ -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
+                                       }
                                }
                        }
                }