瀏覽代碼

[minor] encoding for has_gravatar

version-14
Rushabh Mehta 9 年之前
父節點
當前提交
a5156ec40c
共有 1 個檔案被更改,包括 6 行新增1 行删除
  1. +6
    -1
      frappe/utils/__init__.py

+ 6
- 1
frappe/utils/__init__.py 查看文件

@@ -127,7 +127,12 @@ def has_gravatar(email):
# since querying gravatar for every item will be slow # since querying gravatar for every item will be slow
return '' return ''


gravatar_url = "https://secure.gravatar.com/avatar/{hash}?d=404&s=200".format(hash=md5.md5(email).hexdigest())
if not isinstance(email, unicode):
email = unicode(email, 'utf-8')

hexdigest = md5.md5(email).hexdigest()

gravatar_url = "https://secure.gravatar.com/avatar/{hash}?d=404&s=200".format(hash=hexdigest)
try: try:
res = requests.get(gravatar_url) res = requests.get(gravatar_url)
if res.status_code==200: if res.status_code==200:


Loading…
取消
儲存