From b7a71be2d960a3e266605b69c4f64fe34c9c7eb9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20P=C3=A9ters?= Date: Mon, 16 Jul 2018 16:42:18 +0200 Subject: [PATCH] add python 3 support to signature check (#25296) --- hobo/signature.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/hobo/signature.py b/hobo/signature.py index 52c6ba5..7679872 100644 --- a/hobo/signature.py +++ b/hobo/signature.py @@ -5,6 +5,7 @@ import hashlib import urllib import random +from django.utils import six from django.utils.encoding import smart_bytes from django.utils.http import quote, urlencode from django.utils.six.moves.urllib import parse as urlparse @@ -69,6 +70,10 @@ def check_string(s, signature, key, algo='sha256'): if len(signature2) != len(signature): return False res = 0 - for a, b in zip(signature, signature2): - res |= ord(a) ^ ord(b) + if six.PY3: + for a, b in zip(signature, signature2): + res |= a ^ b + else: + for a, b in zip(signature, signature2): + res |= ord(a) ^ ord(b) return res == 0 -- 2.18.0