summaryrefslogtreecommitdiffstats
path: root/routers/user
diff options
context:
space:
mode:
authorKN4CK3R <KN4CK3R@users.noreply.github.com>2021-06-05 14:32:19 +0200
committerGitHub <noreply@github.com>2021-06-05 15:32:19 +0300
commit8e262104c25d1c2578f683109e1b373aade3a17c (patch)
tree04b8fda8516498b74350bb695f230e0e1089a48d /routers/user
parent7979c3654eb91adce4fd9717d9ff891496a56ff3 (diff)
downloadgitea-8e262104c25d1c2578f683109e1b373aade3a17c.tar.gz
gitea-8e262104c25d1c2578f683109e1b373aade3a17c.zip
Add Image Diff for SVG files (#14867)
* Added type sniffer. * Switched content detection from base to typesniffer. * Added GuessContentType to Blob. * Moved image info logic to client. Added support for SVG images in diff. * Restore old blocked svg behaviour. * Added missing image formats. * Execute image diff only when container is visible. * add margin to spinner * improve BIN tag on image diffs * Default to render view. * Show image diff on incomplete diff. Co-authored-by: silverwind <me@silverwind.io> Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com> Co-authored-by: Lauris BH <lauris@nix.lv>
Diffstat (limited to 'routers/user')
-rw-r--r--routers/user/setting/profile.go5
1 files changed, 4 insertions, 1 deletions
diff --git a/routers/user/setting/profile.go b/routers/user/setting/profile.go
index 8cde81f295..20042caca4 100644
--- a/routers/user/setting/profile.go
+++ b/routers/user/setting/profile.go
@@ -19,6 +19,7 @@ import (
"code.gitea.io/gitea/modules/context"
"code.gitea.io/gitea/modules/log"
"code.gitea.io/gitea/modules/setting"
+ "code.gitea.io/gitea/modules/typesniffer"
"code.gitea.io/gitea/modules/util"
"code.gitea.io/gitea/modules/web"
"code.gitea.io/gitea/modules/web/middleware"
@@ -159,7 +160,9 @@ func UpdateAvatarSetting(ctx *context.Context, form *forms.AvatarForm, ctxUser *
if err != nil {
return fmt.Errorf("ioutil.ReadAll: %v", err)
}
- if !base.IsImageFile(data) {
+
+ st := typesniffer.DetectContentType(data)
+ if !(st.IsImage() && !st.IsSvgImage()) {
return errors.New(ctx.Tr("settings.uploaded_avatar_not_a_image"))
}
if err = ctxUser.UploadAvatar(data); err != nil {