summaryrefslogtreecommitdiff
path: root/modules/gallery/helpers/photo.php
diff options
context:
space:
mode:
authorBharat Mediratta <bharat@menalto.com>2013-02-09 10:35:04 -0800
committerBharat Mediratta <bharat@menalto.com>2013-02-09 10:35:04 -0800
commit7613d886f98299c36d667908c52401bd07eef1e0 (patch)
treea31c4425c6a18a2691b3bf33f86c6a0dcff27689 /modules/gallery/helpers/photo.php
parentf4ecb7e65850ca0cac9f7d963c34f7cd20ee9446 (diff)
parent0312d1b071bd4434ddb3f82888b0323da6bf3732 (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/gallery/helpers/photo.php')
-rw-r--r--modules/gallery/helpers/photo.php9
1 files changed, 8 insertions, 1 deletions
diff --git a/modules/gallery/helpers/photo.php b/modules/gallery/helpers/photo.php
index 51e51507..2d32f0d3 100644
--- a/modules/gallery/helpers/photo.php
+++ b/modules/gallery/helpers/photo.php
@@ -133,8 +133,15 @@ class photo_Core {
$metadata->height = 0;
}
- // Run photo_get_file_metadata events which can modify the class, then return results.
+ // Run photo_get_file_metadata events which can modify the class.
module::event("photo_get_file_metadata", $file_path, $metadata);
+
+ // If the post-events results are invalid, throw an exception.
+ if (!$metadata->width || !$metadata->height || !$metadata->mime_type || !$metadata->extension ||
+ ($metadata->mime_type != legal_file::get_photo_types_by_extension($metadata->extension))) {
+ throw new Exception("@todo ILLEGAL_OR_UNINDENTIFIABLE_FILE");
+ }
+
return array($metadata->width, $metadata->height, $metadata->mime_type, $metadata->extension);
}
}