From 9c78515c72f248d994b54c17485c76599087f166 Mon Sep 17 00:00:00 2001 From: Cinhi Young Date: Mon, 8 Feb 2021 19:33:09 +0800 Subject: [PATCH] Fix: email address should be lowercase for requesting Gravatar (#758) --- service/user/setting.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/service/user/setting.go b/service/user/setting.go index 7561320..ad7f54b 100644 --- a/service/user/setting.go +++ b/service/user/setting.go @@ -7,6 +7,7 @@ import ( "net/url" "os" "path/filepath" + "strings" model "github.com/cloudreve/Cloudreve/v3/models" "github.com/cloudreve/Cloudreve/v3/pkg/serializer" @@ -200,8 +201,8 @@ func (service *AvatarService) Get(c *gin.Context) serializer.Response { if err != nil { return serializer.Err(serializer.CodeInternalSetting, "无法解析 Gravatar 服务器地址", err) } - - has := md5.Sum([]byte(user.Email)) + email_lowered := strings.ToLower(user.Email) + has := md5.Sum([]byte(email_lowered)) avatar, _ := url.Parse(fmt.Sprintf("/avatar/%x?d=mm&s=%s", has, sizes[service.Size])) return serializer.Response{