summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormathieui <mathieui@mathieui.net>2013-05-10 13:41:13 +0200
committermathieui <mathieui@mathieui.net>2013-05-10 13:41:13 +0200
commit6767d04a1d89a3666403172079f1b69ec9eb121c (patch)
treec5fee1bc71a0c64235c1baf0ff9ffcc676a4bcb3
parentca8b67fca9448b2082a07b55c799b852f32fa623 (diff)
downloadpoezio-6767d04a1d89a3666403172079f1b69ec9eb121c.tar.gz
poezio-6767d04a1d89a3666403172079f1b69ec9eb121c.tar.bz2
poezio-6767d04a1d89a3666403172079f1b69ec9eb121c.tar.xz
poezio-6767d04a1d89a3666403172079f1b69ec9eb121c.zip
Fix #2295 (sanitize commands given to /help)
remove starting slashes and starting and trailing spaces
-rw-r--r--src/core.py14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/core.py b/src/core.py
index 6766ef6a..d57605fa 100644
--- a/src/core.py
+++ b/src/core.py
@@ -1362,15 +1362,17 @@ class Core(object):
msg = '\n'.join(buff)
msg += _("\nType /help <command_name> to know what each command does")
if args:
- if args[0] in self.commands:
- tup = self.commands[args[0]]
- elif args[0] in self.current_tab().commands:
- tup = self.current_tab().commands[args[0]]
+ command = args[0].lstrip('/').strip()
+
+ if command in self.commands:
+ tup = self.commands[command]
+ elif command in self.current_tab().commands:
+ tup = self.current_tab().commands[command]
else:
- self.information(_('Unknown command: %s') % args[0], 'Error')
+ self.information(_('Unknown command: %s') % command, 'Error')
return
if isinstance(tup, Command):
- msg = _('Usage: /%s %s\n' % (args[0], tup.usage))
+ msg = _('Usage: /%s %s\n' % (command, tup.usage))
msg += tup.desc
else:
msg = tup[1]