From fe0b0559818b3d70c97c9081ec633927550892a8 Mon Sep 17 00:00:00 2001 From: nickago Date: Tue, 11 Aug 2015 12:19:23 -0700 Subject: [PATCH] Added server side validation of jpegs as images --- model/file.go | 4 ++-- web/react/components/file_upload.jsx | 6 ------ 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/model/file.go b/model/file.go index 3d38ddbd15..6055cbc9a9 100644 --- a/model/file.go +++ b/model/file.go @@ -13,8 +13,8 @@ const ( ) var ( - IMAGE_EXTENSIONS = [4]string{".jpg", ".gif", ".bmp", ".png"} - IMAGE_MIME_TYPES = map[string]string{".jpg": "image/jpeg", ".gif": "image/gif", ".bmp": "image/bmp", ".png": "image/png", ".tiff": "image/tiff"} + IMAGE_EXTENSIONS = [5]string{".jpg", ".jpeg", ".gif", ".bmp", ".png"} + IMAGE_MIME_TYPES = map[string]string{".jpg": "image/jpeg", ".jepg": "image/jpeg", ".gif": "image/gif", ".bmp": "image/bmp", ".png": "image/png", ".tiff": "image/tiff"} ) type FileUploadResponse struct { diff --git a/web/react/components/file_upload.jsx b/web/react/components/file_upload.jsx index b90fa4fd37..0638e71091 100644 --- a/web/react/components/file_upload.jsx +++ b/web/react/components/file_upload.jsx @@ -101,9 +101,6 @@ module.exports = React.createClass({ for (var i = 0; i < items.length; i++) { if (items[i].type.indexOf('image') !== -1) { var ext = items[i].type.split('/')[1].toLowerCase(); - if (ext === 'jpeg') { - ext = 'jpg'; - } if (Constants.IMAGE_TYPES.indexOf(ext) < 0) { continue; @@ -124,9 +121,6 @@ module.exports = React.createClass({ var file = items[i].getAsFile(); var ext = items[i].type.split('/')[1].toLowerCase(); - if (ext === 'jpeg') { - ext = 'jpg'; - } if (Constants.IMAGE_TYPES.indexOf(ext) < 0) { continue;