Loading django/core/signing.py +4 −4 Original line number Diff line number Diff line Loading @@ -40,13 +40,11 @@ import datetime import json import re import time import warnings import zlib from django.conf import settings from django.utils import baseconv from django.utils.crypto import constant_time_compare, salted_hmac from django.utils.deprecation import RemovedInDjango110Warning from django.utils.encoding import force_bytes, force_str, force_text from django.utils.module_loading import import_string Loading Loading @@ -158,8 +156,10 @@ class Signer(object): self.key = key or settings.SECRET_KEY self.sep = force_str(sep) if _SEP_UNSAFE.match(self.sep): warnings.warn('Unsafe Signer separator: %r (cannot be empty or consist of only A-z0-9-_=)' % sep, RemovedInDjango110Warning) raise ValueError( 'Unsafe Signer separator: %r (cannot be empty or consist of ' 'only A-z0-9-_=)' % sep, ) self.salt = force_str(salt or '%s.%s' % (self.__class__.__module__, self.__class__.__name__)) Loading tests/signing/tests.py +2 −6 Original line number Diff line number Diff line from __future__ import unicode_literals import datetime import warnings from django.core import signing from django.test import SimpleTestCase Loading Loading @@ -121,14 +120,11 @@ class TestSigner(SimpleTestCase): def test_invalid_sep(self): """should warn on invalid separator""" msg = 'Unsafe Signer separator: %r (cannot be empty or consist of only A-z0-9-_=)' separators = ['', '-', 'abc'] for sep in separators: with warnings.catch_warnings(record=True) as recorded: warnings.simplefilter('always') with self.assertRaisesMessage(ValueError, msg % sep): signing.Signer(sep=sep) self.assertEqual(len(recorded), 1) msg = str(recorded[0].message) self.assertTrue(msg.startswith('Unsafe Signer separator')) class TestTimestampSigner(SimpleTestCase): Loading Loading
django/core/signing.py +4 −4 Original line number Diff line number Diff line Loading @@ -40,13 +40,11 @@ import datetime import json import re import time import warnings import zlib from django.conf import settings from django.utils import baseconv from django.utils.crypto import constant_time_compare, salted_hmac from django.utils.deprecation import RemovedInDjango110Warning from django.utils.encoding import force_bytes, force_str, force_text from django.utils.module_loading import import_string Loading Loading @@ -158,8 +156,10 @@ class Signer(object): self.key = key or settings.SECRET_KEY self.sep = force_str(sep) if _SEP_UNSAFE.match(self.sep): warnings.warn('Unsafe Signer separator: %r (cannot be empty or consist of only A-z0-9-_=)' % sep, RemovedInDjango110Warning) raise ValueError( 'Unsafe Signer separator: %r (cannot be empty or consist of ' 'only A-z0-9-_=)' % sep, ) self.salt = force_str(salt or '%s.%s' % (self.__class__.__module__, self.__class__.__name__)) Loading
tests/signing/tests.py +2 −6 Original line number Diff line number Diff line from __future__ import unicode_literals import datetime import warnings from django.core import signing from django.test import SimpleTestCase Loading Loading @@ -121,14 +120,11 @@ class TestSigner(SimpleTestCase): def test_invalid_sep(self): """should warn on invalid separator""" msg = 'Unsafe Signer separator: %r (cannot be empty or consist of only A-z0-9-_=)' separators = ['', '-', 'abc'] for sep in separators: with warnings.catch_warnings(record=True) as recorded: warnings.simplefilter('always') with self.assertRaisesMessage(ValueError, msg % sep): signing.Signer(sep=sep) self.assertEqual(len(recorded), 1) msg = str(recorded[0].message) self.assertTrue(msg.startswith('Unsafe Signer separator')) class TestTimestampSigner(SimpleTestCase): Loading