mirror of
https://github.com/postgres/pgweb.git
synced 2025-07-25 16:02:27 +00:00
Fix unicode for hashlib operations
This commit is contained in:
@ -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],
|
||||
)
|
||||
|
||||
|
||||
|
@ -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([
|
||||
|
@ -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
|
||||
|
Reference in New Issue
Block a user