diff options
author | Bharat Mediratta <bharat@menalto.com> | 2010-12-14 21:18:40 -0800 |
---|---|---|
committer | Bharat Mediratta <bharat@menalto.com> | 2010-12-14 21:19:25 -0800 |
commit | 79740a2c77ad5c9b048e094cc164fd0129aba16a (patch) | |
tree | fc24b2fb2dcdb4a350a180c5efb857816b89e5dc /modules/gallery/models | |
parent | d6866544142506b1ad26d72bc46f8746f7365d7b (diff) |
Move photo/movie file extension validation into the model. Fixes #1524.
Diffstat (limited to 'modules/gallery/models')
-rw-r--r-- | modules/gallery/models/item.php | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/modules/gallery/models/item.php b/modules/gallery/models/item.php index 9016a04a..a4d24b8f 100644 --- a/modules/gallery/models/item.php +++ b/modules/gallery/models/item.php @@ -848,10 +848,17 @@ class Item_Model_Core extends ORM_MPTT { } } else { // New items must have an extension - if (!pathinfo($this->name, PATHINFO_EXTENSION)) { + $ext = pathinfo($this->name, PATHINFO_EXTENSION); + if (!$ext) { $v->add_error("name", "illegal_data_file_extension"); return; } + + if ($this->is_movie() && !preg_match("/^(flv|mp4|m4v)$/i", $ext)) { + $v->add_error("name", "illegal_data_file_extension"); + } else if ($this->is_photo() && !preg_match("/^(gif|jpg|jpeg|png)$/i", $ext)) { + $v->add_error("name", "illegal_data_file_extension"); + } } } |