diff options
| author | Bharat Mediratta <bharat@menalto.com> | 2013-02-09 10:35:04 -0800 |
|---|---|---|
| committer | Bharat Mediratta <bharat@menalto.com> | 2013-02-09 10:35:04 -0800 |
| commit | 7613d886f98299c36d667908c52401bd07eef1e0 (patch) | |
| tree | a31c4425c6a18a2691b3bf33f86c6a0dcff27689 /modules/watermark/controllers | |
| parent | f4ecb7e65850ca0cac9f7d963c34f7cd20ee9446 (diff) | |
| parent | 0312d1b071bd4434ddb3f82888b0323da6bf3732 (diff) | |
Merge pull request #128 from shadlaws/fix_1994
#1994 - Make get_file_metadata throw an exception if photo or movie is unidentifiable/illegal.
Diffstat (limited to 'modules/watermark/controllers')
| -rw-r--r-- | modules/watermark/controllers/admin_watermarks.php | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/modules/watermark/controllers/admin_watermarks.php b/modules/watermark/controllers/admin_watermarks.php index 27c2efc9..59bb7fa9 100644 --- a/modules/watermark/controllers/admin_watermarks.php +++ b/modules/watermark/controllers/admin_watermarks.php @@ -102,18 +102,17 @@ class Admin_Watermarks_Controller extends Admin_Controller { $name = preg_replace("/uploadfile-[^-]+-(.*)/", '$1', $pathinfo["basename"]); $name = legal_file::smash_extensions($name); - list ($width, $height, $mime_type, $extension) = photo::get_file_metadata($file); - if (!$width || !$height || !$mime_type || !$extension || - !legal_file::get_photo_extensions($extension)) { - message::error(t("Invalid or unidentifiable image file")); - @unlink($file); - return; - } else { + try { + list ($width, $height, $mime_type, $extension) = photo::get_file_metadata($file); // Force correct, legal extension type on file, which will be of our canonical type // (i.e. all lowercase, jpg instead of jpeg, etc.). This renaming prevents the issues // addressed in ticket #1855, where an image that looked valid (header said jpg) with a // php extension was previously accepted without changing its extension. $name = legal_file::change_extension($name, $extension); + } catch (Exception $e) { + message::error(t("Invalid or unidentifiable image file")); + @unlink($file); + return; } rename($file, VARPATH . "modules/watermark/$name"); |
