From 00b91fe46218be23e040813aacbc73987b9015a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maxime=20=E2=80=9Cpep=E2=80=9D=20Buquet?= Date: Wed, 1 Apr 2020 01:16:11 +0200 Subject: [PATCH] reorder: Ensure valid JID MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Maxime “pep” Buquet --- plugins/reorder.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/plugins/reorder.py b/plugins/reorder.py index ca3bda08..eebc810a 100644 --- a/plugins/reorder.py +++ b/plugins/reorder.py @@ -59,6 +59,8 @@ And finally, the ``[tab name]`` must be: - For a type ``static``, the full JID of the contact """ +from slixmpp import InvalidJID, JID + from poezio import tabs from poezio.decorators import command_args_parser from poezio.plugin import BasePlugin @@ -162,13 +164,18 @@ class Plugin(BasePlugin): new_tabs += [ tabs.GapTab(self.core) for i in range(pos - last - 1) ] - cls, name = tabs_spec[pos] - tab = self.core.tabs.by_name_and_class(name, cls=cls) + cls, jid = tabs_spec[pos] + try: + jid = JID(jid) + except InvalidJID: + self.api.information('Reorder: Invalid JID \'%s\'.' % jid, 'Warning') + continue + tab = self.core.tabs.by_name_and_class(str(jid), cls=cls) if tab and tab in old_tabs: new_tabs.append(tab) old_tabs.remove(tab) else: - self.api.information('Tab %s not found' % name, 'Warning') + self.api.information('Tab %s not found' % jid, 'Warning') if create_gaps: new_tabs.append(tabs.GapTab(self.core)) last = pos