try/catch around request.get_cookie to catch stupid CookieError

This commit is contained in:
Alexandre Aubin 2020-04-25 17:17:45 +02:00 committed by GitHub
parent db29a9aa38
commit 0033c6f0ec
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -362,13 +362,24 @@ class _ActionsMapPlugin(object):
"""
# Retrieve session values
try:
s_id = request.get_cookie("session.id") or random_ascii()
except:
# Super rare case where there are super weird cookie / cache issue
# Previous line throws a CookieError that creates a 500 error ...
# So let's catch it and just use a fresh ID then...
s_id = random_ascii()
try:
s_secret = self.secrets[s_id]
except KeyError:
s_tokens = {}
else:
try:
s_tokens = request.get_cookie("session.tokens", secret=s_secret) or {}
except:
# Same as for session.id a few lines before
s_tokens = {}
s_new_token = random_ascii()
try: