summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--poezio/bookmarks.py8
-rw-r--r--poezio/contact.py16
-rw-r--r--poezio/core/core.py5
3 files changed, 18 insertions, 11 deletions
diff --git a/poezio/bookmarks.py b/poezio/bookmarks.py
index 0406de94..ced6fde6 100644
--- a/poezio/bookmarks.py
+++ b/poezio/bookmarks.py
@@ -32,9 +32,8 @@ import functools
import logging
from typing import Optional, List, Union
-from slixmpp import JID
+from slixmpp import InvalidJID, JID
from slixmpp.plugins.xep_0048 import Bookmarks, Conference, URL
-from poezio.common import safeJID
from poezio.config import config
log = logging.getLogger(__name__)
@@ -288,7 +287,10 @@ class BookmarkList:
return
rooms = rooms.split(':')
for room in rooms:
- jid = safeJID(room)
+ try:
+ jid = JID(room)
+ except InvalidJID:
+ continue
if jid.bare == '':
continue
if jid.resource != '':
diff --git a/poezio/contact.py b/poezio/contact.py
index 27b0598c..50ccab1f 100644
--- a/poezio/contact.py
+++ b/poezio/contact.py
@@ -13,8 +13,7 @@ from collections import defaultdict
import logging
from typing import Dict, Iterator, List, Optional, Union
-from poezio.common import safeJID
-from slixmpp import JID
+from slixmpp import InvalidJID, JID
log = logging.getLogger(__name__)
@@ -134,8 +133,12 @@ class Contact:
return self.__item['subscription']
def __contains__(self, value):
- return value in self.__item.resources or safeJID(
- value).resource in self.__item.resources
+ try:
+ resource = JID(value).resource
+ except InvalidJID:
+ resource = None
+ return value in self.__item.resources or \
+ (resource is not None and resource in self.__item.resources)
def __len__(self) -> int:
"""Number of resources"""
@@ -147,7 +150,10 @@ class Contact:
def __getitem__(self, key) -> Optional[Resource]:
"""Return the corresponding Resource object, or None"""
- res = safeJID(key).resource
+ try:
+ res = JID(key).resource
+ except InvalidJID:
+ return None
resources = self.__item.resources
item = resources.get(res, None) or resources.get(key, None)
return Resource(key, item) if item else None
diff --git a/poezio/core/core.py b/poezio/core/core.py
index 74041429..a99b47d9 100644
--- a/poezio/core/core.py
+++ b/poezio/core/core.py
@@ -35,7 +35,6 @@ from poezio import timed_events
from poezio import windows
from poezio.bookmarks import BookmarkList
-from poezio.common import safeJID
from poezio.config import config, firstrun
from poezio.contact import Contact, Resource
from poezio.daemon import Executor
@@ -1019,7 +1018,7 @@ class Core:
If fallback_barejid is True, then this method will seek other
tabs with the same barejid, instead of searching only by fulljid.
"""
- jid = safeJID(jid)
+ jid = JID(jid)
# We first check if we have a static conversation opened
# with this precise resource
conversation = self.tabs.by_name_and_class(jid.full,
@@ -1164,7 +1163,7 @@ class Core:
provided, we open a StaticConversationTab, else a
DynamicConversationTab
"""
- if safeJID(jid).resource:
+ if jid.resource:
new_tab = tabs.StaticConversationTab(self, jid)
else:
new_tab = tabs.DynamicConversationTab(self, jid)