From 9cd709ba9f92dc898ae770e6a4fcb619bd964ddf Mon Sep 17 00:00:00 2001 From: Exempt-Medic Date: Tue, 10 Dec 2024 15:13:30 -0500 Subject: [PATCH 1/3] Strip passwords --- MultiServer.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/MultiServer.py b/MultiServer.py index 2561b0692a3c..9144fc7112a6 100644 --- a/MultiServer.py +++ b/MultiServer.py @@ -218,8 +218,8 @@ def __init__(self, host: str, port: int, server_password: str, password: str, lo self.allow_releases = {} self.host = host self.port = port - self.server_password = server_password - self.password = password + self.server_password = server_password.strip() + self.password = password.strip() self.server = None self.countdown_timer = 0 self.received_items = {} @@ -2320,7 +2320,7 @@ def value_type(input_text: str): return input_text.lower() not in {"off", "0", "false", "none", "null", "no"} elif value_type == str and option_name.endswith("password"): def value_type(input_text: str): - return None if input_text.lower() in {"null", "none", '""', "''"} else input_text + return None if input_text.lower().strip() in {"null", "none", '""', "''"} else input_text.strip() elif value_type == str and option_name.endswith("mode"): valid_values = {"goal", "enabled", "disabled"} valid_values.update(("auto", "auto_enabled") if option_name != "remaining_mode" else []) From 64290b3395b4b9a2f08aa5d9954ba86a18bf26ce Mon Sep 17 00:00:00 2001 From: Exempt-Medic Date: Tue, 10 Dec 2024 16:10:52 -0500 Subject: [PATCH 2/3] Python and "tricks" --- MultiServer.py | 4 ++-- WebHostLib/generate.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/MultiServer.py b/MultiServer.py index 9144fc7112a6..f27f97f6cb01 100644 --- a/MultiServer.py +++ b/MultiServer.py @@ -218,8 +218,8 @@ def __init__(self, host: str, port: int, server_password: str, password: str, lo self.allow_releases = {} self.host = host self.port = port - self.server_password = server_password.strip() - self.password = password.strip() + self.server_password = server_password and server_password.strip() + self.password = password and password.strip() self.server = None self.countdown_timer = 0 self.received_items = {} diff --git a/WebHostLib/generate.py b/WebHostLib/generate.py index b19f3d483515..c828afb25630 100644 --- a/WebHostLib/generate.py +++ b/WebHostLib/generate.py @@ -35,7 +35,7 @@ def get_meta(options_source: dict, race: bool = False) -> Dict[str, Union[List[s "remaining_mode": options_source.get("remaining_mode", ServerOptions.remaining_mode), "collect_mode": options_source.get("collect_mode", ServerOptions.collect_mode), "item_cheat": bool(int(options_source.get("item_cheat", not ServerOptions.disable_item_cheat))), - "server_password": options_source.get("server_password", None), + "server_password": options_source.get("server_password") and options_source["server_password"].strip(), } generator_options = { "spoiler": int(options_source.get("spoiler", GeneratorOptions.spoiler)), From b8329e22e7119179be0bf86ff5942d1b41b5ff66 Mon Sep 17 00:00:00 2001 From: Exempt-Medic Date: Tue, 10 Dec 2024 17:36:46 -0500 Subject: [PATCH 3/3] Adding comments --- MultiServer.py | 1 + WebHostLib/generate.py | 1 + 2 files changed, 2 insertions(+) diff --git a/MultiServer.py b/MultiServer.py index f27f97f6cb01..acf9ceba5360 100644 --- a/MultiServer.py +++ b/MultiServer.py @@ -218,6 +218,7 @@ def __init__(self, host: str, port: int, server_password: str, password: str, lo self.allow_releases = {} self.host = host self.port = port + # None if None else str.strip() self.server_password = server_password and server_password.strip() self.password = password and password.strip() self.server = None diff --git a/WebHostLib/generate.py b/WebHostLib/generate.py index c828afb25630..443d6d7b6499 100644 --- a/WebHostLib/generate.py +++ b/WebHostLib/generate.py @@ -35,6 +35,7 @@ def get_meta(options_source: dict, race: bool = False) -> Dict[str, Union[List[s "remaining_mode": options_source.get("remaining_mode", ServerOptions.remaining_mode), "collect_mode": options_source.get("collect_mode", ServerOptions.collect_mode), "item_cheat": bool(int(options_source.get("item_cheat", not ServerOptions.disable_item_cheat))), + # None if None else str.strip() "server_password": options_source.get("server_password") and options_source["server_password"].strip(), } generator_options = {