Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Core: Removing leading/trailing whitespace from passwords #4359

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions MultiServer.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,8 +218,9 @@ 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
# None if None else str.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 = {}
Expand Down Expand Up @@ -2320,7 +2321,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 [])
Expand Down
3 changes: 2 additions & 1 deletion WebHostLib/generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ def get_meta(options_source: dict, race: bool = False) -> Dict[str, Union[List[s
"remaining_mode": str(options_source.get("remaining_mode", ServerOptions.remaining_mode)),
"collect_mode": str(options_source.get("collect_mode", ServerOptions.collect_mode)),
"item_cheat": bool(int(options_source.get("item_cheat", not ServerOptions.disable_item_cheat))),
"server_password": str(options_source.get("server_password", None)),
# None if None else str.strip()
"server_password": str(options_source.get("server_password") and options_source["server_password"].strip()),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't like it silently changing it to something we didn't ask for.
I think it would be better to throw an exception if it has spaces.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is how player names and other things are already handled

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would say it's much more visible to all kinds of users & easier to figure out what the change was in case of player names (Web tracker / Room, !players from Text Client) , if my password doesn't work I'd probably panic quite a bit

Apparently, /option password is a thing for the server console, which is at least one way to rectify it
but yeah this change is pretty spooky I think

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know the proper way to make this error on webhost or common client, so I'm probably just going to close this PR

}
generator_options = {
"spoiler": int(options_source.get("spoiler", GeneratorOptions.spoiler)),
Expand Down
Loading