mirror of
				https://github.com/go-gitea/gitea
				synced 2025-11-03 21:08:25 +00:00 
			
		
		
		
	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.
This commit is contained in:
		@@ -48,8 +48,12 @@ func init() {
 | 
				
			|||||||
// hash email to md5 string
 | 
					// hash email to md5 string
 | 
				
			||||||
// keep this func in order to make this package indenpent
 | 
					// keep this func in order to make this package indenpent
 | 
				
			||||||
func HashEmail(email string) string {
 | 
					func HashEmail(email string) string {
 | 
				
			||||||
 | 
						// https://en.gravatar.com/site/implement/hash/
 | 
				
			||||||
 | 
						email = strings.TrimSpace(email)
 | 
				
			||||||
 | 
						email = strings.ToLower(email)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	h := md5.New()
 | 
						h := md5.New()
 | 
				
			||||||
	h.Write([]byte(strings.ToLower(email)))
 | 
						h.Write([]byte(email))
 | 
				
			||||||
	return hex.EncodeToString(h.Sum(nil))
 | 
						return hex.EncodeToString(h.Sum(nil))
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user