Skip to content
This repository was archived by the owner on Oct 22, 2019. It is now read-only.

Commit ae63b07

Browse files
committed
Merge pull request #472 from mortenwh/master
Fixed problem with æ, ø, å in strings sent to utils.generate_sha1 and updated translations
2 parents 26d2b0e + 005bdca commit ae63b07

File tree

3 files changed

+24
-7
lines changed

3 files changed

+24
-7
lines changed

userena/locale/nb/LC_MESSAGES/django.po

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -455,7 +455,7 @@ msgid ""
455455
"We will store your signup information for %(userena_activation_days)s days "
456456
"on our server. "
457457
msgstr ""
458-
"Vi vil lagre din informasjonn på vår server i %(userena_activation_days)s "
458+
"Vi vil lagre din informasjon på vår server i %(userena_activation_days)s "
459459
"dager."
460460

461461
#: templates/userena/disabled.html:4
@@ -474,7 +474,7 @@ msgstr "Det ser ut til at din konto har blitt deaktivert."
474474
msgid ""
475475
"If you feel that injustice has been done to you, feel free to contact the "
476476
"administrators to find out why"
477-
msgstr "Kontakt gjerne administrator hvis du mener vi har gjort deg urett."
477+
msgstr "Kontakt gjerne administrator hvis du mener noe er feil."
478478

479479
#: templates/userena/email_change_complete.html:4
480480
msgid "Email verification"
@@ -731,7 +731,7 @@ msgstr "Du kan nå bruke oppgitt legitimering for å logge inn."
731731
#: templates/userena/emails/confirmation_email_message_new.html:4
732732
#, python-format
733733
msgid "Dear %(username)s,</p>"
734-
msgstr "Kjære %(username)s,</p>"
734+
msgstr "Hei %(username)s,</p>"
735735

736736
#: templates/userena/emails/activation_email_message.html:5
737737
#, python-format
@@ -768,7 +768,7 @@ msgstr "Vennlig hilsen"
768768
#: templates/userena/emails/confirmation_email_message_old.txt:2
769769
#, python-format
770770
msgid "Dear %(username)s,"
771-
msgstr "Kjære %(username)s,"
771+
msgstr "Hei %(username)s,"
772772

773773
#: templates/userena/emails/activation_email_message.txt:4
774774
#, python-format

userena/tests/tests_utils.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1+
import sys, re, six
12

23
from django.test import TestCase
34
from django.conf import settings
45
from django.utils.six.moves.urllib_parse import urlparse, parse_qs
56

67
from userena.utils import (get_gravatar, signin_redirect, get_profile_model,
7-
get_protocol, get_user_model)
8+
get_protocol, get_user_model, generate_sha1)
89
from userena import settings as userena_settings
910
from userena.compat import SiteProfileNotAvailable
1011

@@ -13,6 +14,18 @@ class UtilsTests(TestCase):
1314
""" Test the extra utils methods """
1415
fixtures = ['users']
1516

17+
def test_generate_sha(self):
18+
s1 = six.u('\xc5se')
19+
s2 = six.u('\xd8ystein')
20+
s3 = six.u('\xc6gir')
21+
h1 = generate_sha1(s1)
22+
h2 = generate_sha1(s2)
23+
h3 = generate_sha1(s3)
24+
# Check valid SHA1 activation key
25+
self.failUnless(re.match('^[a-f0-9]{40}$', h1[1]))
26+
self.failUnless(re.match('^[a-f0-9]{40}$', h2[1]))
27+
self.failUnless(re.match('^[a-f0-9]{40}$', h3[1]))
28+
1629
def test_get_gravatar(self):
1730
template = 's=%(size)s&d=%(type)s'
1831

userena/utils.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
from django.conf import settings
22

33
from django.utils.six import text_type
4-
from django.utils.six.moves.urllib.parse import urlencode
4+
try:
5+
from django.utils.six.moves.urllib.parse import urlencode
6+
except ImportError:
7+
from six.moves.urllib.parse import urlencode
8+
from django.utils.encoding import smart_bytes
59

610
from userena import settings as userena_settings
711
from userena.compat import SiteProfileNotAvailable, get_model
@@ -112,7 +116,7 @@ def generate_sha1(string, salt=None):
112116
if not salt:
113117
salt = sha_constructor(str(random.random()).encode('utf-8')).hexdigest()[:5]
114118

115-
salted_bytes = (salt.encode('utf-8') + string.encode('utf-8'))
119+
salted_bytes = (smart_bytes(salt) + smart_bytes(string))
116120
hash_ = sha_constructor(salted_bytes).hexdigest()
117121

118122
return salt, hash_

0 commit comments

Comments
 (0)