summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAsif Saifuddin Auvi <auvipy@users.noreply.github.com>2018-02-07 23:47:34 +0600
committerTim Graham <timograham@gmail.com>2018-02-07 12:47:34 -0500
commitb38532cd6be6ea91b47fd93e9cbaae4aa10015fc (patch)
tree937d145d8717edc61264c8849623b208ff8422f4
parent34b52f85720280572c9e8fd2869f3485a367899b (diff)
Refs #27795 -- Replaced force_bytes() usage in django.core.signing.
-rw-r--r--django/core/signing.py4
1 files changed, 2 insertions, 2 deletions
diff --git a/django/core/signing.py b/django/core/signing.py
index 5daad4d8ef..1a55bcda03 100644
--- a/django/core/signing.py
+++ b/django/core/signing.py
@@ -74,7 +74,7 @@ def base64_hmac(salt, value, key):
def get_cookie_signer(salt='django.core.signing.get_cookie_signer'):
Signer = import_string(settings.SIGNING_BACKEND)
- key = force_bytes(settings.SECRET_KEY)
+ key = force_bytes(settings.SECRET_KEY) # SECRET_KEY may be str or bytes.
return Signer(b'django.http.cookies' + key, salt=salt)
@@ -131,7 +131,7 @@ def loads(s, key=None, salt='django.core.signing', serializer=JSONSerializer, ma
"""
# TimestampSigner.unsign() returns str but base64 and zlib compression
# operate on bytes.
- base64d = force_bytes(TimestampSigner(key, salt=salt).unsign(s, max_age=max_age))
+ base64d = TimestampSigner(key, salt=salt).unsign(s, max_age=max_age).encode()
decompress = base64d[:1] == b'.'
if decompress:
# It's compressed; uncompress it first