From adc1ac689efb23c6de2a22b0d6226d02b1641222 Mon Sep 17 00:00:00 2001 From: Andrew Burns Date: Fri, 5 Dec 2014 10:58:49 -0700 Subject: HashEmail function should also remove spaces According to the [Gravatar API](https://en.gravatar.com/site/implement/hash/) whitespace should also be removed from the email, it was not doing this previously. --- modules/avatar/avatar.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'modules/avatar') diff --git a/modules/avatar/avatar.go b/modules/avatar/avatar.go index 144fda387e..225d6c8183 100644 --- a/modules/avatar/avatar.go +++ b/modules/avatar/avatar.go @@ -48,8 +48,12 @@ func init() { // hash email to md5 string // keep this func in order to make this package indenpent func HashEmail(email string) string { + // https://en.gravatar.com/site/implement/hash/ + email = strings.TrimSpace(email) + email = strings.ToLower(email) + h := md5.New() - h.Write([]byte(strings.ToLower(email))) + h.Write([]byte(email)) return hex.EncodeToString(h.Sum(nil)) } -- cgit v1.2.3