aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMicah Lee <micah@micahflee.com>2024-03-07 19:51:32 -0800
committerMicah Lee <micah@micahflee.com>2024-03-07 19:51:32 -0800
commit3ef52eb59b2fdec07ae8c5cd99ce03caa89c9324 (patch)
treed30c3f4c739ca5848ba6d19e60704066999a6d51
parentfe7bd43f04275a17cb3ab0d31e9a2f5c1ae3e263 (diff)
downloadonionshare-3ef52eb59b2fdec07ae8c5cd99ce03caa89c9324.tar.gz
onionshare-3ef52eb59b2fdec07ae8c5cd99ce03caa89c9324.zip
Handle exceptions in chat mode's validate_username
-rw-r--r--cli/onionshare_cli/web/chat_mode.py18
1 files changed, 11 insertions, 7 deletions
diff --git a/cli/onionshare_cli/web/chat_mode.py b/cli/onionshare_cli/web/chat_mode.py
index 5a11eedd..39899c65 100644
--- a/cli/onionshare_cli/web/chat_mode.py
+++ b/cli/onionshare_cli/web/chat_mode.py
@@ -48,13 +48,17 @@ class ChatModeWeb:
self.define_routes()
def validate_username(self, username):
- username = username.strip()
- return (
- username
- and username.isascii()
- and username not in self.connected_users
- and len(username) < 128
- )
+ try:
+ username = username.strip()
+ return (
+ username
+ and username.isascii()
+ and username not in self.connected_users
+ and len(username) < 128
+ )
+ except Exception as e:
+ self.common.log("ChatModeWeb", "validate_username", e)
+ return False
def define_routes(self):
"""