Merge pull request #2511 from Hiramiya/avatarbannerfiletypes

Prevent setting non-image files as avatar/banner
This commit is contained in:
syuilo 2018-08-28 07:41:50 +09:00 committed by GitHub
commit 77baca8e6e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 28 additions and 0 deletions

View file

@ -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"

View file

@ -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%',

View file

@ -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%',