From 5889d50a0d7ed0115f6ce9e27c23453f025a4031 Mon Sep 17 00:00:00 2001 From: Qeole Date: Sun, 10 May 2020 01:29:44 +0100 Subject: [PATCH] commands: prevent python crash when typing simply "/olm" MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Typing "/olm" on its own is supposed to fall back to the default subcommand "/olm info private". It does pick up "info", but fails to find a "category" (in our case: we want "private") because the category has never been parsed, and has never been assigned to "args". Not only does the command fail, but it even yields a traceback: python : stdout/stderr (matrix) : Traceback (most recent call last): python : stdout/stderr (matrix) : File "/home/qmo/weechat/conf/python/matrix/utf.py", line 89, in wrapper python : stdout/stderr (matrix) : return function(*args, **kwargs) python : stdout/stderr (matrix) : File "/home/qmo/weechat/conf/python/matrix/commands.py", line 891, in matrix_olm_command_cb python : stdout/stderr (matrix) : return command(server, data, buffer, args) python : stdout/stderr (matrix) : File "/home/qmo/weechat/conf/python/matrix/commands.py", line 860, in command python : stdout/stderr (matrix) : olm_info_command(server, parsed_args) python : stdout/stderr (matrix) : File "/home/qmo/weechat/conf/python/matrix/commands.py", line 594, in olm_info_command python : stdout/stderr (matrix) : if args.category == "private": python : stdout/stderr (matrix) : AttributeError: 'Namespace' object has no attribute 'category' Fix it by going for "private" if no category has been assigned. Fixes: 1208c9d4a2e3 ("commands: Add initial olm command.") --- matrix/commands.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/matrix/commands.py b/matrix/commands.py index 0e0ed2d..3a66b42 100644 --- a/matrix/commands.py +++ b/matrix/commands.py @@ -591,7 +591,7 @@ def olm_info_command(server, args): olm = server.client.olm - if args.category == "private": + if not hasattr(args, 'category') or args.category == "private": fp_key = partition_key(olm.account.identity_keys["ed25519"]) message = ("Identity keys:\n" " - User: {user_color}{user}{ncolor}\n"