mirror of
https://github.com/django/django.git
synced 2024-12-25 02:26:12 +00:00
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.
This commit is contained in:
parent
2aebd79a9c
commit
1a66f53f94
@ -156,9 +156,6 @@ class PreviewTests(TestCase):
|
|||||||
|
|
||||||
|
|
||||||
class FormHmacTests(unittest.TestCase):
|
class FormHmacTests(unittest.TestCase):
|
||||||
"""
|
|
||||||
Same as SecurityHashTests, but with form_hmac
|
|
||||||
"""
|
|
||||||
|
|
||||||
def test_textfield_hash(self):
|
def test_textfield_hash(self):
|
||||||
"""
|
"""
|
||||||
@ -166,8 +163,8 @@ class FormHmacTests(unittest.TestCase):
|
|||||||
leading/trailing whitespace so as to be friendly to broken browsers that
|
leading/trailing whitespace so as to be friendly to broken browsers that
|
||||||
submit it (usually in textareas).
|
submit it (usually in textareas).
|
||||||
"""
|
"""
|
||||||
f1 = HashTestForm({'name': 'joe', 'bio': 'Nothing notable.'})
|
f1 = HashTestForm({'name': u'joe', 'bio': u'Nothing notable.'})
|
||||||
f2 = HashTestForm({'name': ' joe', 'bio': 'Nothing notable. '})
|
f2 = HashTestForm({'name': u' joe', 'bio': u'Nothing notable. '})
|
||||||
hash1 = utils.form_hmac(f1)
|
hash1 = utils.form_hmac(f1)
|
||||||
hash2 = utils.form_hmac(f2)
|
hash2 = utils.form_hmac(f2)
|
||||||
self.assertEqual(hash1, hash2)
|
self.assertEqual(hash1, hash2)
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
try:
|
# Do not try cPickle here (see #18340)
|
||||||
import cPickle as pickle
|
import pickle
|
||||||
except ImportError:
|
|
||||||
import pickle
|
|
||||||
|
|
||||||
from django.utils.crypto import salted_hmac
|
from django.utils.crypto import salted_hmac
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user