mirror of
https://github.com/django-q2/django-q2.git
synced 2026-09-20 11:28:34 +08:00
Merge pull request #448 from edouardtheron/fix-deprecation-warning
Use 'force_str' instead of deprecated 'force_text'
This commit is contained in:
@@ -6,7 +6,7 @@ from django.core.signing import BadSignature, SignatureExpired, b64_decode, JSON
|
||||
Signer as Sgnr, TimestampSigner as TsS, dumps
|
||||
from django.utils import baseconv
|
||||
from django.utils.crypto import constant_time_compare
|
||||
from django.utils.encoding import force_bytes, force_str, force_text
|
||||
from django.utils.encoding import force_bytes, force_str
|
||||
|
||||
dumps = dumps
|
||||
|
||||
@@ -39,14 +39,12 @@ def loads(s, key=None, salt='django.core.signing', serializer=JSONSerializer, ma
|
||||
class Signer(Sgnr):
|
||||
|
||||
def unsign(self, signed_value):
|
||||
# force_str is removed in Django 2.0
|
||||
signed_value = force_str(signed_value)
|
||||
if self.sep not in signed_value:
|
||||
raise BadSignature('No "%s" found in value' % self.sep)
|
||||
value, sig = signed_value.rsplit(self.sep, 1)
|
||||
if constant_time_compare(sig, self.signature(value)):
|
||||
# force_text is removed in Django 2.0
|
||||
return force_text(value)
|
||||
return force_str(value)
|
||||
raise BadSignature('Signature "%s" does not match' % sig)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user