Changeset - c1080b42a7cb
[Not reviewed]
beta
0 1 0
Marcin Kuzminski - 15 years ago 2011-02-27 03:18:23
marcin@python-works.com
fixed problem with int. chars in gravatars
1 file changed with 9 insertions and 7 deletions:
0 comments (0 inline, 0 general)
rhodecode/lib/helpers.py
Show inline comments
 
@@ -6,12 +6,12 @@ available to Controllers. This module is
 
import random
 
import hashlib
 
import StringIO
 
import urllib
 

	
 
from pygments.formatters import HtmlFormatter
 
from pygments import highlight as code_highlight
 
from pylons import url
 
from pylons import url, request
 
from pylons.i18n.translation import _, ungettext
 
from vcs.utils.annotate import annotate_highlight
 
from rhodecode.lib.utils import repo_name_slug
 

	
 
from webhelpers.html import literal, HTML, escape
 
from webhelpers.html.tools import *
 
@@ -33,6 +33,9 @@ from webhelpers.paginate import Page
 
from webhelpers.html.tags import _set_input_attrs, _set_id_attr, \
 
    convert_boolean_attrs, NotGiven
 

	
 
from vcs.utils.annotate import annotate_highlight
 
from rhodecode.lib.utils import repo_name_slug
 

	
 
def _reset(name, value=None, id=NotGiven, type="reset", **attrs):
 
    """Reset button
 
    """
 
@@ -557,9 +560,6 @@ HasRepoPermissionAny, HasRepoPermissionA
 
#==============================================================================
 
# GRAVATAR URL
 
#==============================================================================
 
import hashlib
 
import urllib
 
from pylons import request
 

	
 
def gravatar_url(email_address, size=30):
 
    ssl_enabled = 'https' == request.environ.get('wsgi.url_scheme')
 
@@ -568,7 +568,9 @@ def gravatar_url(email_address, size=30)
 
    baseurl_ssl = "https://secure.gravatar.com/avatar/"
 
    baseurl = baseurl_ssl if ssl_enabled else baseurl_nossl
 

	
 

	
 
    if isinstance(email_address, unicode):
 
        #hashlib crashes on unicode items
 
        email_address = email_address.encode('utf8', 'replace')
 
    # construct the url
 
    gravatar_url = baseurl + hashlib.md5(email_address.lower()).hexdigest() + "?"
 
    gravatar_url += urllib.urlencode({'d':default, 's':str(size)})
0 comments (0 inline, 0 general)