From d693479d05f1ada999c0e29a9d9e2f021dd59e50 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maxime=20=E2=80=9Cpep=E2=80=9D=20Buquet?= Date: Sun, 7 Apr 2019 22:14:13 +0100 Subject: safeJID: Remove some safeJID calls MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Maxime “pep” Buquet --- poezio/core/commands.py | 3 ++- poezio/core/core.py | 14 ++++++++++++-- 2 files changed, 14 insertions(+), 3 deletions(-) (limited to 'poezio/core') diff --git a/poezio/core/commands.py b/poezio/core/commands.py index e785a93b..f7946b71 100644 --- a/poezio/core/commands.py +++ b/poezio/core/commands.py @@ -369,7 +369,8 @@ class CommandCore: # New tab if tab is None: tab = self.core.open_new_room(room, nick, password=password) - tab.join() + if tab is not None: + tab.join() else: self.core.focus_tab(tab) if tab.own_nick == nick and tab.joined: diff --git a/poezio/core/core.py b/poezio/core/core.py index 7553c57d..91eb4877 100644 --- a/poezio/core/core.py +++ b/poezio/core/core.py @@ -1179,7 +1179,12 @@ class Core: """ Open a Private conversation in a MUC and focus if needed. """ - complete_jid = room_name + '/' + user_nick + try: + complete_jid_str = room_name + '/' + user_nick + complete_jid = JID(complete_jid_str) + except InvalidJID: + self.information('Invalid XMPP address %r for chat tab.', complete_jid_str) + return None # if the room exists, focus it and return for tab in self.get_tabs(tabs.PrivateTab): if tab.name == complete_jid: @@ -1205,10 +1210,15 @@ class Core: nick: str, *, password: Optional[str] = None, - focus=True) -> tabs.MucTab: + focus=True) -> Optional[tabs.MucTab]: """ Open a new tab.MucTab containing a muc Room, using the specified nick """ + try: + room = JID(room) + except InvalidJID: + self.information('Invalid XMPP address %r for chat tab.', room) + return None new_tab = tabs.MucTab(self, room, nick, password=password) self.add_tab(new_tab, focus) self.refresh_window() -- cgit v1.2.3