From efc7b22bdb316633fb50af3b674ee117aefc8619 Mon Sep 17 00:00:00 2001 From: "louiz@4325f9fc-e183-4c21-96ce-0ab188b42d13" Date: Sat, 11 Sep 2010 04:07:04 +0000 Subject: You can now kick ANYONE (even with a space), and have a space in your nick. fixed #1803 --- src/gui.py | 41 ++++++++++++++++++++++++++++++----------- 1 file changed, 30 insertions(+), 11 deletions(-) diff --git a/src/gui.py b/src/gui.py index 7207a7a4..b6e6ded3 100644 --- a/src/gui.py +++ b/src/gui.py @@ -20,9 +20,10 @@ from os.path import isfile from time import sleep -import sys import os import re +import sys +import shlex import curses import webbrowser @@ -760,7 +761,11 @@ class Gui(object): """ # TODO return - args = arg.split() + # check shlex here + try: + args = shlex.split(arg) + except ValueError as error: + return self.add_message_to_room(self.current_room(), _("Error: %s") % (error)) room = self.current_room() if len(args) != 1: self.add_message_to_room(room, _('whois command takes exactly one argument')) @@ -809,7 +814,10 @@ class Gui(object): """ /kick [reason] """ - args = arg.split() + try: + args = shlex.split(arg) + except ValueError as error: + return self.add_message_to_room(self.current_room(), _("Error: %s") % (error)) if len(args) < 1: self.command_help('kick') return @@ -980,7 +988,10 @@ class Gui(object): """ /ignore """ - args = arg.split() + try: + args = shlex.split(arg) + except ValueError as error: + return self.add_message_to_room(self.current_room(), _("Error: %s") % (error)) if len(args) != 1: self.command_help('ignore') return @@ -1000,7 +1011,10 @@ class Gui(object): """ /unignore """ - args = arg.split() + try: + args = shlex.split(arg) + except ValueError as error: + return self.add_message_to_room(self.current_room(), _("Error: %s") % (error)) if len(args) != 1: self.command_help('unignore') return @@ -1065,7 +1079,10 @@ class Gui(object): """ /query [message] """ - args = arg.split() + try: + args = shlex.split(arg) + except ValueError as error: + return self.add_message_to_room(self.current_room(), _("Error: %s") % (error)) if len(args) < 1: return nick = args[0] @@ -1085,13 +1102,12 @@ class Gui(object): """ /topic [new topic] """ - args = arg.split() room = self.current_room() - if len(args) == 0: + if not arg.strip(): self.add_message_to_room(room, _("The subject of the room is: %s") % room.topic) return - subject = ' '.join(args) - if not room.joined or room.name == "Info": + subject = arg + if not room.joined or room.name == "Info" and not room.jid: return muc.change_subject(self.xmpp, room.name, subject) @@ -1145,7 +1161,10 @@ class Gui(object): """ /nick """ - args = arg.split() + try: + args = shlex.split(arg) + except ValueError as error: + return self.add_message_to_room(self.current_room(), _("Error: %s") % (error)) if len(args) != 1: return nick = args[0] -- cgit v1.2.3