Python 3.6: Fixed issue with gravatar function
Hashing of string object doesn't work. Also added a deprecation warning that pillar.api.utils.gravatar should be used; pillar.web.utils.gravatar is just a copy.
This commit is contained in:
@@ -141,10 +141,10 @@ def str2id(document_id):
|
|||||||
raise wz_exceptions.BadRequest('Invalid object ID %r' % document_id)
|
raise wz_exceptions.BadRequest('Invalid object ID %r' % document_id)
|
||||||
|
|
||||||
|
|
||||||
def gravatar(email, size=64):
|
def gravatar(email: str, size=64):
|
||||||
parameters = {'s': str(size), 'd': 'mm'}
|
parameters = {'s': str(size), 'd': 'mm'}
|
||||||
return "https://www.gravatar.com/avatar/" + \
|
return "https://www.gravatar.com/avatar/" + \
|
||||||
hashlib.md5(str(email)).hexdigest() + \
|
hashlib.md5(email.encode()).hexdigest() + \
|
||||||
"?" + urllib.parse.urlencode(parameters)
|
"?" + urllib.parse.urlencode(parameters)
|
||||||
|
|
||||||
|
|
||||||
|
@@ -49,11 +49,13 @@ def attach_project_pictures(project, api):
|
|||||||
project.picture_header = get_file(project.picture_header, api=api)
|
project.picture_header = get_file(project.picture_header, api=api)
|
||||||
|
|
||||||
|
|
||||||
def gravatar(email, size=64):
|
def gravatar(email: str, size=64):
|
||||||
parameters = {'s': str(size), 'd': 'mm'}
|
import warnings
|
||||||
return "https://www.gravatar.com/avatar/" + \
|
warnings.warn("the pillar.web.gravatar function is deprecated; use hashlib instead",
|
||||||
hashlib.md5(str(email)).hexdigest() + \
|
DeprecationWarning, 2)
|
||||||
"?" + urllib.parse.urlencode(parameters)
|
|
||||||
|
from pillar.api.utils import gravatar as api_gravatar
|
||||||
|
return api_gravatar(email, size)
|
||||||
|
|
||||||
|
|
||||||
def datetime_now():
|
def datetime_now():
|
||||||
|
Reference in New Issue
Block a user