diff options
author | Andrew Burns <ErebusBat@gmail.com> | 2014-12-05 10:58:49 -0700 |
---|---|---|
committer | Andrew Burns <ErebusBat@gmail.com> | 2014-12-05 10:58:49 -0700 |
commit | adc1ac689efb23c6de2a22b0d6226d02b1641222 (patch) | |
tree | c29b927201d4c1c9f4add159005bb50a526fc20b | |
parent | e577f2fff38957316a2b6d584cad9bc7abaf732b (diff) | |
download | gitea-adc1ac689efb23c6de2a22b0d6226d02b1641222.tar.gz gitea-adc1ac689efb23c6de2a22b0d6226d02b1641222.zip |
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.
-rw-r--r-- | modules/avatar/avatar.go | 6 |
1 files changed, 5 insertions, 1 deletions
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)) } |