From 8c3b781e6cfde200d044d4f7acaa4da9fdd68d07 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9ophile=20Diot?= Date: Fri, 15 Mar 2024 10:36:01 +0000 Subject: [PATCH] Fix plugin removal and variable handling in main.py of the web UI --- src/ui/main.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/ui/main.py b/src/ui/main.py index f7589f690..c26ca3d6f 100755 --- a/src/ui/main.py +++ b/src/ui/main.py @@ -330,8 +330,9 @@ def run_action(plugin: str, function_name: str = ""): finally: if sbin_nginx_path.is_file(): # Remove the custom plugin from the shared library - sys_path.pop() - sys_modules.pop("actions") + if sys_path: + sys_path.pop() + sys_modules.pop("actions", None) del actions if message or not isinstance(res, dict) and not res: @@ -813,7 +814,7 @@ def services(): # Check variables variables = deepcopy(request.form.to_dict()) del variables["csrf_token"] - is_draft = variables.pop("is_draft") == "yes" + is_draft = variables.pop("is_draft", "no") == "yes" if "OLD_SERVER_NAME" not in request.form and request.form["operation"] == "edit": return redirect_flash_error("Missing OLD_SERVER_NAME parameter.", "services", True) @@ -1974,7 +1975,7 @@ def bans(): bans = bans[:100] for ban in bans: - exp = ban.pop("exp") + exp = ban.pop("exp", 0) # Add remain ban["remain"], ban["term"] = ("unknown", "unknown") if exp <= 0 else get_remain(exp) # Convert stamp to date