From d1a956113554d3be174207d90770eb5d4875cd46 Mon Sep 17 00:00:00 2001 From: Hiramiya Date: Mon, 27 Aug 2018 20:03:28 +0100 Subject: [PATCH 1/3] Restrict avatar filetypes --- src/client/app/desktop/api/update-avatar.ts | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/client/app/desktop/api/update-avatar.ts b/src/client/app/desktop/api/update-avatar.ts index 18b912d14..f07dc623f 100644 --- a/src/client/app/desktop/api/update-avatar.ts +++ b/src/client/app/desktop/api/update-avatar.ts @@ -6,6 +6,19 @@ import ProgressDialog from '../views/components/progress-dialog.vue'; export default (os: OS) => { const cropImage = file => new Promise((resolve, reject) => { + + var regex = RegExp('\.(jpg|jpeg|png|gif|webp|bmp|tiff)$') + if(!regex.test(file.name) ) { + os.apis.dialog({ + title: '%fa:info-circle% %i18n:desktop.invalid-filetype%', + text: null, + actions: [{ + text: '%i18n:common.got-it%' + }] + }); + reject + } + const w = os.new(CropWindow, { image: file, title: '%i18n:desktop.avatar-crop-title%', From e7e6d833b7039957cc58bdf0b673156a65f3cc92 Mon Sep 17 00:00:00 2001 From: Hiramiya Date: Mon, 27 Aug 2018 20:03:48 +0100 Subject: [PATCH 2/3] Restrict banner filetypes --- src/client/app/desktop/api/update-banner.ts | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/client/app/desktop/api/update-banner.ts b/src/client/app/desktop/api/update-banner.ts index 33c4e306a..5af6ea88d 100644 --- a/src/client/app/desktop/api/update-banner.ts +++ b/src/client/app/desktop/api/update-banner.ts @@ -6,6 +6,20 @@ import ProgressDialog from '../views/components/progress-dialog.vue'; export default (os: OS) => { const cropImage = file => new Promise((resolve, reject) => { + + var regex = RegExp('\.(jpg|jpeg|png|gif|webp|bmp|tiff)$') + + if(!regex.test(file.name) ) { + os.apis.dialog({ + title: '%fa:info-circle% %i18n:desktop.invalid-filetype%', + text: null, + actions: [{ + text: '%i18n:common.got-it%' + }] + }); + reject + } + const w = os.new(CropWindow, { image: file, title: '%i18n:desktop.banner-crop-title%', From 14ad3af30d36dbc28d8e85973144aaa6f36efe77 Mon Sep 17 00:00:00 2001 From: Hiramiya Date: Mon, 27 Aug 2018 20:04:39 +0100 Subject: [PATCH 3/3] Add "invalid-filetype" translation --- locales/en-US.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/locales/en-US.yml b/locales/en-US.yml index bc2dbc86f..c7c24433e 100644 --- a/locales/en-US.yml +++ b/locales/en-US.yml @@ -411,6 +411,7 @@ desktop: uploading-avatar: "Uploading a new avatar" avatar-updated: "Successfully updated the avatar" choose-avatar: "Select an image for the avatar" + invalid-filetype: "This filetype is not acceptable here" desktop/views/components/activity.chart.vue: total: "Black ... Total" notes: "Blue ... Notes"