mirror of
https://github.com/zulip/zulip.git
synced 2025-11-10 17:07:07 +00:00
Always give hashlib.sha1 and friends bytes.
This fixes an experienced bug where you couldn't subscribe to a stream with non-ASCII characters (failing with a UnicodeEncodeError), as well as many other potential bugs. (imported from commit f084a4b4b597b85935655097a7b5a163811c4d71)
This commit is contained in:
@@ -1,5 +1,11 @@
|
||||
import hashlib
|
||||
from utils import make_safe_digest
|
||||
|
||||
def gravatar_hash(email):
|
||||
"""Compute the Gravatar hash for an email address."""
|
||||
return hashlib.md5(email.lower()).hexdigest()
|
||||
# Non-ASCII characters aren't permitted by the currently active e-mail
|
||||
# RFCs. However, the IETF has published https://tools.ietf.org/html/rfc4952,
|
||||
# outlining internationalization of email addresses, and regardless if we
|
||||
# typo an address or someone manages to give us a non-ASCII address, let's
|
||||
# not error out on it.
|
||||
return make_safe_digest(email.lower(), hashlib.md5)
|
||||
|
||||
Reference in New Issue
Block a user