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.main
parent
cb5557cc2e
commit
ddc73a53fe
|
@ -70,21 +70,21 @@ def session_required(f):
|
||||||
# Clear out old sessions
|
# Clear out old sessions
|
||||||
invalid_sessions = []
|
invalid_sessions = []
|
||||||
for user_session in os.listdir(app.config['SESSION_FILE_DIR']):
|
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'],
|
app.config['SESSION_FILE_DIR'],
|
||||||
user_session)
|
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:
|
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)
|
_ = pickle.load(session_file)
|
||||||
data = pickle.load(session_file)
|
data = pickle.load(session_file)
|
||||||
if isinstance(data, dict) and 'valid' in data:
|
if isinstance(data, dict) and 'valid' in data:
|
||||||
continue
|
continue
|
||||||
invalid_sessions.append(session_path)
|
invalid_sessions.append(file_path)
|
||||||
except (EOFError, FileNotFoundError, pickle.UnpicklingError):
|
except (EOFError, FileNotFoundError, pickle.UnpicklingError):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
|
@ -93,7 +93,7 @@
|
||||||
<select name="country" id="config-country">
|
<select name="country" id="config-country">
|
||||||
{% for country in countries %}
|
{% for country in countries %}
|
||||||
<option value="{{ country.value }}"
|
<option value="{{ country.value }}"
|
||||||
{% if country.value in config.country %}
|
{% if config.country in country.value %}
|
||||||
selected
|
selected
|
||||||
{% endif %}>
|
{% endif %}>
|
||||||
{{ country.name }}
|
{{ country.name }}
|
||||||
|
|
Loading…
Reference in New Issue