mirror of
https://github.com/zulip/zulip.git
synced 2025-11-06 15:03:34 +00:00
Fix use of invalid hash keys with memcached.
Email addresses can contain characters that are not valid for memcached cache keys. (imported from commit d7cfd6d5292e4fc8f4e2b19f2c01a4097d878f1b)
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
from functools import wraps
|
from functools import wraps
|
||||||
|
import hashlib
|
||||||
|
|
||||||
from django.core.cache import cache as djcache
|
from django.core.cache import cache as djcache
|
||||||
from django.core.cache import get_cache
|
from django.core.cache import get_cache
|
||||||
@@ -55,7 +56,7 @@ def message_cache_key(message_id):
|
|||||||
return "message:%d" % (message_id,)
|
return "message:%d" % (message_id,)
|
||||||
|
|
||||||
def userprofile_by_email_cache_key(email):
|
def userprofile_by_email_cache_key(email):
|
||||||
return 'tornado_user_profile_by_email:%s' % (email,)
|
return 'tornado_user_profile_by_email:%s' % (hashlib.sha1(email).hexdigest(),)
|
||||||
|
|
||||||
def userprofile_by_user_cache_key(user_id):
|
def userprofile_by_user_cache_key(user_id):
|
||||||
return 'tornado_user_profile_by_user:%d' % (user_id,)
|
return 'tornado_user_profile_by_user:%d' % (user_id,)
|
||||||
|
|||||||
Reference in New Issue
Block a user