mirror of
https://github.com/django-q2/django-q2.git
synced 2026-10-04 20:08:13 +08:00
Merge branch 'master' into type_hints
This commit is contained in:
@@ -13,7 +13,7 @@ from django.core.signing import (
|
|||||||
)
|
)
|
||||||
from django.utils import baseconv
|
from django.utils import baseconv
|
||||||
from django.utils.crypto import constant_time_compare
|
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
|
dumps = dumps
|
||||||
|
|
||||||
@@ -51,14 +51,12 @@ def loads(
|
|||||||
|
|
||||||
class Signer(Sgnr):
|
class Signer(Sgnr):
|
||||||
def unsign(self, signed_value):
|
def unsign(self, signed_value):
|
||||||
# force_str is removed in Django 2.0
|
|
||||||
signed_value = force_str(signed_value)
|
signed_value = force_str(signed_value)
|
||||||
if self.sep not in signed_value:
|
if self.sep not in signed_value:
|
||||||
raise BadSignature('No "%s" found in value' % self.sep)
|
raise BadSignature('No "%s" found in value' % self.sep)
|
||||||
value, sig = signed_value.rsplit(self.sep, 1)
|
value, sig = signed_value.rsplit(self.sep, 1)
|
||||||
if constant_time_compare(sig, self.signature(value)):
|
if constant_time_compare(sig, self.signature(value)):
|
||||||
# force_text is removed in Django 2.0
|
return force_str(value)
|
||||||
return force_text(value)
|
|
||||||
raise BadSignature('Signature "%s" does not match' % sig)
|
raise BadSignature('Signature "%s" does not match' % sig)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user