Permalink
Browse files

Fix encoding error with non-ascii passwords.

  • Loading branch information...
dnouri committed Jun 7, 2012
1 parent 9bd0c76 commit 1fa5d282b60c98f307c8bdf3b08958825922c476
Showing with 7 additions and 1 deletion.
  1. +2 −0 CHANGES.txt
  2. +2 −1 kotti/security.py
  3. +3 −0 kotti/tests/test_security.py
View
@@ -4,6 +4,8 @@ Change History
0.7a3 - Unreleased
------------------
+- Fix encoding error with non-ascii passwords.
+
0.7a2 - 2012-06-07
------------------
View
@@ -464,7 +464,8 @@ def search(self, **kwargs):
def hash_password(self, password, hashed=None):
if hashed is None:
hashed = bcrypt.gensalt(self.log_rounds)
- return unicode(bcrypt.hashpw(password, hashed))
+ return unicode(
+ bcrypt.hashpw(password.encode('utf-8'), hashed.encode('utf-8')))
def validate_password(self, clear, hashed):
try:
@@ -418,6 +418,9 @@ def _assert_is_bob(self, bob):
self.assertEqual(bob.title, u'Bob Dabolina')
self.assertEqual(bob.groups, [u'group:bobsgroup'])
+ def test_hash_password_non_ascii(self):
+ self.get_principals().hash_password(u'\xd6TEst')
+
def test_default_admin(self):
admin = self.get_principals()[u'admin']
self.assertTrue(

0 comments on commit 1fa5d28

Please sign in to comment.