Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fixed #18340 -- Fixed formtools form_hmac with Unicode input

Using cPickle, two apparently identical Unicode strings could
generate different pickled results depending on previous operations
on those strings.
  • Loading branch information...
commit 1a66f53f9413583d1da266356bb35e5f82868641 1 parent 2aebd79
@claudep claudep authored
View
7 django/contrib/formtools/tests/__init__.py
@@ -156,9 +156,6 @@ def test_form_submit_bad_hash(self):
class FormHmacTests(unittest.TestCase):
- """
- Same as SecurityHashTests, but with form_hmac
- """
def test_textfield_hash(self):
"""
@@ -166,8 +163,8 @@ def test_textfield_hash(self):
leading/trailing whitespace so as to be friendly to broken browsers that
submit it (usually in textareas).
"""
- f1 = HashTestForm({'name': 'joe', 'bio': 'Nothing notable.'})
- f2 = HashTestForm({'name': ' joe', 'bio': 'Nothing notable. '})
+ f1 = HashTestForm({'name': u'joe', 'bio': u'Nothing notable.'})
+ f2 = HashTestForm({'name': u' joe', 'bio': u'Nothing notable. '})
hash1 = utils.form_hmac(f1)
hash2 = utils.form_hmac(f2)
self.assertEqual(hash1, hash2)
View
6 django/contrib/formtools/utils.py
@@ -1,7 +1,5 @@
-try:
- import cPickle as pickle
-except ImportError:
- import pickle
+# Do not try cPickle here (see #18340)
+import pickle
from django.utils.crypto import salted_hmac
Please sign in to comment.
Something went wrong with that request. Please try again.