From ddc73a53fe9055899c9df271fb6e4d5ed766da5f Mon Sep 17 00:00:00 2001 From: Ben Busby Date: Thu, 16 Jun 2022 12:11:23 -0600 Subject: [PATCH] Flip country config check in template Country config value should be checked against the valid value when updating the home page config, not the other way around. This can lead to a state where a user sets up an invalid country value, but can still be matched against a correct value that is part of the invalid value (i.e. "countryUK" is invalid, but would match against the correct value, "UK") Also minor refactor of where the session file size validation occurs. --- app/routes.py | 14 +++++++------- app/templates/index.html | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/app/routes.py b/app/routes.py index 1f58a7d..d236682 100644 --- a/app/routes.py +++ b/app/routes.py @@ -70,21 +70,21 @@ def session_required(f): # Clear out old sessions invalid_sessions = [] for user_session in os.listdir(app.config['SESSION_FILE_DIR']): - session_path = os.path.join( + file_path = os.path.join( app.config['SESSION_FILE_DIR'], user_session) - # Ignore any files that are larger than the max session file size - if os.path.getsize(session_path) > app.config['MAX_SESSION_SIZE']: - continue - try: - with open(session_path, 'rb') as session_file: + # Ignore files that are larger than the max session file size + if os.path.getsize(file_path) > app.config['MAX_SESSION_SIZE']: + continue + + with open(file_path, 'rb') as session_file: _ = pickle.load(session_file) data = pickle.load(session_file) if isinstance(data, dict) and 'valid' in data: continue - invalid_sessions.append(session_path) + invalid_sessions.append(file_path) except (EOFError, FileNotFoundError, pickle.UnpicklingError): pass diff --git a/app/templates/index.html b/app/templates/index.html index 10f6b6f..21821f9 100644 --- a/app/templates/index.html +++ b/app/templates/index.html @@ -93,7 +93,7 @@