mirror of
https://github.com/Hopiu/wagtail.git
synced 2026-05-10 16:24:49 +00:00
Merge branch 'vden-gravatar-idn-email-fix'
This commit is contained in:
commit
13c8e4da58
5 changed files with 24 additions and 4 deletions
|
|
@ -39,6 +39,7 @@ Changelog
|
|||
* Fix: Searching a specific page model while filtering it by either ID or tree position no longer raises an error (Ashia Zawaduk)
|
||||
* Fix: Scrolling an over-long explorer menu no longer causes white background to show through (Alex Gleason)
|
||||
* Fix: Removed jitter when hovering over StreamField blocks (Alex Gleason)
|
||||
* Fix: Non-ASCII email addresses no longer throw errors when generating Gravatar URLs (Denis Voskvitsov, Kyle Stratis)
|
||||
|
||||
1.1 (15.09.2015)
|
||||
~~~~~~~~~~~~~~~~
|
||||
|
|
|
|||
|
|
@ -75,6 +75,8 @@ Contributors
|
|||
* Josh Barr
|
||||
* Sævar Öfjörð Magnússon
|
||||
* Ashia Zawaduk
|
||||
* Denis Voskvitsov
|
||||
* Kyle Stratis
|
||||
|
||||
|
||||
Translators
|
||||
|
|
|
|||
|
|
@ -93,6 +93,7 @@ Bug fixes
|
|||
* Searching a specific page model while filtering it by either ID or tree position no longer raises an error (Ashia Zawaduk)
|
||||
* Scrolling an over-long explorer menu no longer causes white background to show through (Alex Gleason)
|
||||
* Removed jitter when hovering over StreamField blocks (Alex Gleason)
|
||||
* Non-ASCII email addresses no longer throw errors when generating Gravatar URLs (Denis Voskvitsov, Kyle Stratis)
|
||||
|
||||
Upgrade considerations
|
||||
======================
|
||||
|
|
|
|||
|
|
@ -10,7 +10,6 @@
|
|||
import hashlib
|
||||
|
||||
from django import template
|
||||
from django.utils.six import b
|
||||
from django.utils.six.moves.urllib.parse import urlencode
|
||||
|
||||
register = template.Library()
|
||||
|
|
@ -28,13 +27,16 @@ class GravatarUrlNode(template.Node):
|
|||
return ''
|
||||
|
||||
default = "blank"
|
||||
size = int(self.size) * 2 # requested at retina size by default and scaled down at point of use with css
|
||||
size = int(self.size) * 2 # requested at retina size by default and scaled down at point of use with css
|
||||
|
||||
gravatar_url = "//www.gravatar.com/avatar/" + hashlib.md5(b(email.lower())).hexdigest() + "?"
|
||||
gravatar_url += urlencode({'s': str(size), 'd': default})
|
||||
gravatar_url = "//www.gravatar.com/avatar/{hash}?{params}".format(
|
||||
hash=hashlib.md5(email.lower().encode('utf-8')).hexdigest(),
|
||||
params=urlencode({'s': size, 'd': default})
|
||||
)
|
||||
|
||||
return gravatar_url
|
||||
|
||||
|
||||
@register.tag
|
||||
def gravatar_url(parser, token):
|
||||
bits = token.split_contents()
|
||||
|
|
|
|||
|
|
@ -1,8 +1,13 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import json
|
||||
|
||||
from django.test import TestCase, override_settings
|
||||
from django.core.urlresolvers import reverse
|
||||
from django.core import mail
|
||||
from django.contrib.auth import get_user_model
|
||||
|
||||
from taggit.models import Tag
|
||||
|
||||
|
|
@ -41,6 +46,15 @@ class TestHome(TestCase, WagtailTestUtils):
|
|||
self.assertIn('no-store', response['Cache-Control'])
|
||||
self.assertIn('max-age=0', response['Cache-Control'])
|
||||
|
||||
def test_nonascii_email(self):
|
||||
# Test that non-ASCII email addresses don't break the admin; previously these would
|
||||
# cause a failure when generating Gravatar URLs
|
||||
get_user_model().objects.create_superuser(username='snowman', email='☃@thenorthpole.com', password='password')
|
||||
# Login
|
||||
self.client.login(username='snowman', password='password')
|
||||
response = self.client.get(reverse('wagtailadmin_home'))
|
||||
self.assertEqual(response.status_code, 200)
|
||||
|
||||
|
||||
class TestEditorHooks(TestCase, WagtailTestUtils):
|
||||
def setUp(self):
|
||||
|
|
|
|||
Loading…
Reference in a new issue