summaryrefslogtreecommitdiff
path: root/modules/watermark
diff options
context:
space:
mode:
authorshadlaws <shad@shadlaws.com>2013-02-08 13:51:41 +0100
committershadlaws <shad@shadlaws.com>2013-02-08 13:51:41 +0100
commit0312d1b071bd4434ddb3f82888b0323da6bf3732 (patch)
treece89c93a8ebde82d5e576804ec253bc5a0747017 /modules/watermark
parent40c5cba2dccdb217bd93274f65d16fd5558257fe (diff)
#1994 - Make get_file_metadata throw an exception if photo or movie is unidentifiable/illegal.
- photo & movie helpers: modified to throw exceptions when file is known to be unidentifiable/illegal. - item model: revised to work with exceptions and be more explicit when the data file is invalid. - item model: removed duplicate get_file_metadata call for updated items. - admin_watermarks controller: revised to work with exceptions (really cleans up logic here). - graphics helper: revised to handle invalid placeholders (a nearly-impossible corner case, but still...). - photo & movie helper tests: revised to work with exceptions, added new tests for illegal files with valid extensions. - item model tests: revised to work with exceptions, added new tests for illegal files with valid extensions.
Diffstat (limited to 'modules/watermark')
-rw-r--r--modules/watermark/controllers/admin_watermarks.php13
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");