From 2fdc73c35b7a9b7135eacc56c9c2de9969acaba4 Mon Sep 17 00:00:00 2001 From: s3lph Date: Wed, 11 Dec 2024 01:35:32 +0100 Subject: [PATCH] fix: default values of config options SignupKioskMode and BarcodeWebsocketAcl did not work --- matemat/webserver/pagelets/signup.py | 3 ++- matemat/webserver/template/template.py | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/matemat/webserver/pagelets/signup.py b/matemat/webserver/pagelets/signup.py index 99f19e0..d1bb453 100644 --- a/matemat/webserver/pagelets/signup.py +++ b/matemat/webserver/pagelets/signup.py @@ -70,7 +70,8 @@ def signup(): elif request.method != 'GET': abort(405, 'Method not allowed') - acl = netaddr.IPSet([addr.strip() for addr in config.get('SignupKioskMode', '').split(',')]) + acl_addrs = [s.strip() for s in config.get('SignupKioskMode', '').split(',') if s.strip()] + acl = netaddr.IPSet(acl_addrs) if request.remote_addr in acl: return template.render('signup_kiosk.html', signup=(config.get('SignupEnabled', '0') == '1'), diff --git a/matemat/webserver/template/template.py b/matemat/webserver/template/template.py index f9bbf4b..ba116f4 100644 --- a/matemat/webserver/template/template.py +++ b/matemat/webserver/template/template.py @@ -29,7 +29,8 @@ def render(name: str, **kwargs): global __jinja_env config = get_app_config() template: jinja2.Template = __jinja_env.get_template(name) - wsacl = netaddr.IPSet([addr.strip() for addr in config.get('BarcodeWebsocketAcl', '').split(',')]) + wsacl_addrs = [s.strip() for s in config.get('BarcodeWebsocketAcl', '').split(',') if s.strip()] + wsacl = netaddr.IPSet(wsacl_addrs) if config.get('BarcodeWebsocketUrl', '') and hasattr(request, 'remote_addr') and request.remote_addr in wsacl: bcwebsocket = config.get('BarcodeWebsocketUrl') else: