summaryrefslogtreecommitdiff
path: root/pgweb/util/middleware.py
diff options
context:
space:
mode:
authorMagnus Hagander2020-11-18 10:28:40 +0000
committerMagnus Hagander2020-11-18 10:28:40 +0000
commit0387d17e2d2ff9304c18f06bab0b996ead54a4da (patch)
treea685ab8640bc4e77664ae15774d4cc9e9cfe89bf /pgweb/util/middleware.py
parent8cd2181be845fc750086a29dd1d887d2f5c874a2 (diff)
Replace non-ascii chars in template names when building xkey
We don't have non-ascii characters in any of our correct URLs, but people can still specify them on the URL. In this case the xkey isn't going to match anything anyway, so it is not critical how we handle it, especially since the generated page is going to be a 404 anyway. So just use the simple built-in replace function.
Diffstat (limited to 'pgweb/util/middleware.py')
-rw-r--r--pgweb/util/middleware.py2
1 files changed, 1 insertions, 1 deletions
diff --git a/pgweb/util/middleware.py b/pgweb/util/middleware.py
index e16796fd..acbb7f3f 100644
--- a/pgweb/util/middleware.py
+++ b/pgweb/util/middleware.py
@@ -40,7 +40,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.encode('ascii')).hexdigest()) for t in tlist])
+ response['xkey'] = ' '.join(["pgwt_{0}".format(hashlib.md5(t.encode('ascii', errors='replace')).hexdigest()) for t in tlist])
# Set security headers
sources = OrderedDict([