summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMagnus Hagander2019-01-19 19:12:52 +0000
committerMagnus Hagander2019-01-26 15:19:26 +0000
commitb7f0398c15cd2a060b84d178d7fba60add7a96e7 (patch)
treeba76e99e346943fa3864ad07d79c5f33db18e7a6
parentc6c0bf1948b0c675d01f54f5698d5fd10c0c557e (diff)
Fix unicode for hashlib operations
-rw-r--r--pgweb/misc/views.py2
-rw-r--r--pgweb/util/middleware.py2
-rwxr-xr-xtools/purgehook/purgehook.py2
3 files changed, 3 insertions, 3 deletions
diff --git a/pgweb/misc/views.py b/pgweb/misc/views.py
index a70b7633..c8d7e2db 100644
--- a/pgweb/misc/views.py
+++ b/pgweb/misc/views.py
@@ -21,7 +21,7 @@ from .forms import SubmitBugForm
def _make_bugs_messageid(bugid):
return "<{0}-{1}@postgresql.org>".format(
bugid,
- hashlib.md5("{0}-{1}".format(os.getpid(), time.time())).hexdigest()[:16],
+ hashlib.md5("{0}-{1}".format(os.getpid(), time.time()).encode('ascii')).hexdigest()[:16],
)
diff --git a/pgweb/util/middleware.py b/pgweb/util/middleware.py
index 941de86e..fa7803f7 100644
--- a/pgweb/util/middleware.py
+++ b/pgweb/util/middleware.py
@@ -38,7 +38,7 @@ class PgMiddleware(object):
response['x-do-esi'] = "1"
tlist.remove('base/esi.html')
if tlist:
- response['xkey'] = ' '.join(["pgwt_{0}".format(hashlib.md5(t).hexdigest()) for t in tlist])
+ response['xkey'] = ' '.join(["pgwt_{0}".format(hashlib.md5(t.encode('ascii')).hexdigest()) for t in tlist])
# Set security headers
sources = OrderedDict([
diff --git a/tools/purgehook/purgehook.py b/tools/purgehook/purgehook.py
index 291fdac0..a4a6131a 100755
--- a/tools/purgehook/purgehook.py
+++ b/tools/purgehook/purgehook.py
@@ -28,7 +28,7 @@ if __name__ == "__main__":
tmpl = l[len('templates/'):].strip()
if tmpl not in BANNED_TEMPLATES:
curs.execute("SELECT varnish_purge_xkey(%(key)s)", {
- 'key': 'pgwt_{0}'.format(hashlib.md5(tmpl).hexdigest()),
+ 'key': 'pgwt_{0}'.format(hashlib.md5(tmpl.encode('ascii')).hexdigest()),
})
elif l.startswith('media/'):
# For media we can't xkey, but the URL is exact so we can