Skip to content

Commit

Permalink
Replace all Gravatar URLs with scheme relative URLs
Browse files Browse the repository at this point in the history
If the site is deployed under https the insecure
gravatar embed will prevent the browser from
showing a nice green logo. Loading everything
over the same schema is sensible.
  • Loading branch information
stefanw committed Feb 20, 2013
1 parent 91086ac commit 6fd1a21
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion ckan/lib/helpers.py
Expand Up @@ -687,7 +687,7 @@ def gravatar(email_hash, size=100, default=None):
# treat the default as a url
default = urllib.quote(default, safe='')

return literal('''<img src="http://gravatar.com/avatar/%s?s=%d&amp;d=%s"
return literal('''<img src="//gravatar.com/avatar/%s?s=%d&amp;d=%s"
class="gravatar" width="%s" height="%s" />'''
% (email_hash, size, default, size, size)
)
Expand Down
4 changes: 2 additions & 2 deletions ckan/tests/functional/test_pagination.py
Expand Up @@ -20,11 +20,11 @@ def scrape_search_results(response, object_type):
def test_scrape_user():
html = '''
<li class="username">
<img src="http://gravatar.com/avatar/d41d8cd98f00b204e9800998ecf8427e?s=16&amp;d=http://test.ckan.net/images/icons/user.png" /> <a href="/user/user_00">user_00</a>
<img src="//gravatar.com/avatar/d41d8cd98f00b204e9800998ecf8427e?s=16&amp;d=http://test.ckan.net/images/icons/user.png" /> <a href="/user/user_00">user_00</a>
</li>
...
<li class="username">
<img src="http://gravatar.com/avatar/d41d8cd98f00b204e9800998ecf8427e?s=16&amp;d=http://test.ckan.net/images/icons/user.png" /> <a href="/user/user_01">user_01</a>
<img src="//gravatar.com/avatar/d41d8cd98f00b204e9800998ecf8427e?s=16&amp;d=http://test.ckan.net/images/icons/user.png" /> <a href="/user/user_01">user_01</a>
</li>
'''
Expand Down
6 changes: 3 additions & 3 deletions ckan/tests/lib/test_helpers.py
Expand Up @@ -81,7 +81,7 @@ def test_time_ago_in_words_from_str(self):
def test_gravatar(self):
email = 'zephod@gmail.com'
expected = ['<a href="https://gravatar.com/"',
'<img src="http://gravatar.com/avatar/7856421db6a63efa5b248909c472fbd2?s=200&amp;d=mm"', '</a>']
'<img src="//gravatar.com/avatar/7856421db6a63efa5b248909c472fbd2?s=200&amp;d=mm"', '</a>']
# Hash the email address
import hashlib
email_hash = hashlib.md5(email).hexdigest()
Expand All @@ -94,7 +94,7 @@ def test_gravatar_config_set_default(self):
email = 'zephod@gmail.com'
default = config.get('ckan.gravatar_default', 'identicon')
expected = ['<a href="https://gravatar.com/"',
'<img src="http://gravatar.com/avatar/7856421db6a63efa5b248909c472fbd2?s=200&amp;d=%s"' % default,
'<img src="//gravatar.com/avatar/7856421db6a63efa5b248909c472fbd2?s=200&amp;d=%s"' % default,
'</a>']
# Hash the email address
import hashlib
Expand All @@ -108,7 +108,7 @@ def test_gravatar_encodes_url_correctly(self):
email = 'zephod@gmail.com'
default = 'http://example.com/images/avatar.jpg'
expected = ['<a href="https://gravatar.com/"',
'<img src="http://gravatar.com/avatar/7856421db6a63efa5b248909c472fbd2?s=200&amp;d=http%3A%2F%2Fexample.com%2Fimages%2Favatar.jpg"',
'<img src="//gravatar.com/avatar/7856421db6a63efa5b248909c472fbd2?s=200&amp;d=http%3A%2F%2Fexample.com%2Fimages%2Favatar.jpg"',
'</a>']
# Hash the email address
import hashlib
Expand Down

0 comments on commit 6fd1a21

Please sign in to comment.