summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorsyuilo <Syuilotan@yahoo.co.jp>2018-08-28 07:41:50 +0900
committerGitHub <noreply@github.com>2018-08-28 07:41:50 +0900
commit77baca8e6ef0b7a9ef37c94e6bbc6622663ef073 (patch)
treef0deb4c3c4e7d7cb31d6e9545117841acd99f87f /src
parentMerge pull request #2509 from Hiramiya/updateavatarfix (diff)
parentAdd "invalid-filetype" translation (diff)
downloadsharkey-77baca8e6ef0b7a9ef37c94e6bbc6622663ef073.tar.gz
sharkey-77baca8e6ef0b7a9ef37c94e6bbc6622663ef073.tar.bz2
sharkey-77baca8e6ef0b7a9ef37c94e6bbc6622663ef073.zip
Merge pull request #2511 from Hiramiya/avatarbannerfiletypes
Prevent setting non-image files as avatar/banner
Diffstat (limited to 'src')
-rw-r--r--src/client/app/desktop/api/update-avatar.ts13
-rw-r--r--src/client/app/desktop/api/update-banner.ts14
2 files changed, 27 insertions, 0 deletions
diff --git a/src/client/app/desktop/api/update-avatar.ts b/src/client/app/desktop/api/update-avatar.ts
index 18b912d148..f07dc623f2 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%',
diff --git a/src/client/app/desktop/api/update-banner.ts b/src/client/app/desktop/api/update-banner.ts
index 33c4e306a2..5af6ea88d2 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%',