From ec745db5710d96fdda05e937b73b00bddb89a4c2 Mon Sep 17 00:00:00 2001 From: Magnus Hagander Date: Mon, 23 Nov 2020 11:57:40 +0100 Subject: [PATCH] Allow additions to auto-generated xkey tags If an xkey tag is already set on a response when it reaches the middleware, add it to the set of automated xkeys generated from the templates instead of overwriting it. --- pgweb/util/middleware.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pgweb/util/middleware.py b/pgweb/util/middleware.py index acbb7f3f..1609e001 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', errors='replace')).hexdigest()) for t in tlist]) + response['xkey'] = ' '.join(["pgwt_{0}".format(hashlib.md5(t.encode('ascii', errors='replace')).hexdigest()) for t in tlist] + [response.get('xkey', '')]) # Set security headers sources = OrderedDict([ -- 2.39.5