summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'plugins')
-rw-r--r--plugins/otr.py31
-rwxr-xr-xplugins/qr.py9
-rw-r--r--plugins/server_part.py12
-rw-r--r--plugins/uptime.py2
4 files changed, 35 insertions, 19 deletions
diff --git a/plugins/otr.py b/plugins/otr.py
index b3848d2d..23843788 100644
--- a/plugins/otr.py
+++ b/plugins/otr.py
@@ -184,7 +184,6 @@ and :term:`log` configuration parameters are tab-specific.
from gettext import gettext as _
import logging
-log = logging.getLogger(__name__)
import os
import html
import curses
@@ -194,10 +193,11 @@ import potr
from potr.context import NotEncryptedError, UnencryptedMessage, ErrorReceived, NotOTRMessage,\
STATE_ENCRYPTED, STATE_PLAINTEXT, STATE_FINISHED, Context, Account, crypt
+from slixmpp import JID, InvalidJID
+
from poezio import common
from poezio import xdg
from poezio import xhtml
-from poezio.common import safeJID
from poezio.config import config
from poezio.plugin import BasePlugin
from poezio.roster import roster
@@ -207,6 +207,8 @@ from poezio.decorators import command_args_parser
from poezio.core.structs import Completion
from poezio.ui.types import InfoMessage, Message
+log = logging.getLogger(__name__)
+
POLICY_FLAGS = {
'ALLOW_V1': False,
'ALLOW_V2': True,
@@ -345,7 +347,7 @@ class PoezioContext(Context):
self.xmpp = xmpp
self.core = core
self.flags = {}
- self.trustName = safeJID(peer).bare
+ self.trustName = JID(peer).bare
self.in_smp = False
self.smp_own = False
self.log = 0
@@ -375,7 +377,7 @@ class PoezioContext(Context):
'info': '\x19%s}' % dump_tuple(get_theme().COLOR_INFORMATION_TEXT),
'normal': '\x19%s}' % dump_tuple(get_theme().COLOR_NORMAL_TEXT),
'jid': self.peer,
- 'bare_jid': safeJID(self.peer).bare
+ 'bare_jid': JID(self.peer).bare
}
tab = self.core.tabs.by_name(self.peer)
@@ -461,8 +463,9 @@ class PoezioAccount(Account):
if acc != self.name or proto != 'xmpp':
continue
- jid = safeJID(ctx).bare
- if not jid:
+ try:
+ jid = JID(ctx).bare
+ except InvalidJID:
continue
self.setTrust(jid, fpr, trust)
except:
@@ -595,7 +598,7 @@ class Plugin(BasePlugin):
"""
Retrieve or create an OTR context
"""
- jid = safeJID(jid)
+ jid = JID(jid)
if jid.full not in self.contexts:
flags = POLICY_FLAGS.copy()
require = self.config.get_by_tabname(
@@ -806,9 +809,11 @@ class Plugin(BasePlugin):
Find an OTR session from a bare JID.
"""
for ctx in self.contexts:
- if safeJID(
- ctx
- ).bare == bare_jid and self.contexts[ctx].state == STATE_ENCRYPTED:
+ try:
+ jid = JID(ctx).bare
+ except InvalidJID:
+ continue
+ if jid == bare_jid and self.contexts[ctx].state == STATE_ENCRYPTED:
return self.contexts[ctx]
return None
@@ -880,7 +885,11 @@ class Plugin(BasePlugin):
Returns the text to display in the infobar (the OTR status)
"""
context = self.get_context(jid)
- if safeJID(jid).bare == jid and context.state != STATE_ENCRYPTED:
+ try:
+ bare_jid = JID(jid).bare
+ except InvalidJID:
+ bare_jid = ''
+ if bare_jid == jid and context.state != STATE_ENCRYPTED:
ctx = self.find_encrypted_context_with_matching(jid)
if ctx:
context = ctx
diff --git a/plugins/qr.py b/plugins/qr.py
index a6d325aa..735c3002 100755
--- a/plugins/qr.py
+++ b/plugins/qr.py
@@ -6,9 +6,10 @@ import qrcode
from typing import Dict, Callable
+from slixmpp import JID, InvalidJID
+
from poezio import windows
from poezio.tabs import Tab
-from poezio.common import safeJID
from poezio.core.structs import Command
from poezio.decorators import command_args_parser
from poezio.plugin import BasePlugin
@@ -170,7 +171,11 @@ class Plugin(BasePlugin):
def command_invite(self, args):
server = self.core.xmpp.boundjid.domain
if len(args) > 0:
- server = safeJID(args[0])
+ try:
+ server = JID(args[0])
+ except InvalidJID:
+ self.api.information(f'Invalid JID: {args[0]}', 'Error')
+ return
session = {
'next' : self.on_next,
'error': self.core.handler.adhoc_error
diff --git a/plugins/server_part.py b/plugins/server_part.py
index f29b4099..cae2248e 100644
--- a/plugins/server_part.py
+++ b/plugins/server_part.py
@@ -16,10 +16,10 @@ Command
"""
+from slixmpp import JID, InvalidJID
from poezio.plugin import BasePlugin
from poezio.tabs import MucTab
from poezio.decorators import command_args_parser
-from poezio.common import safeJID
from poezio.core.structs import Completion
@@ -42,13 +42,15 @@ class Plugin(BasePlugin):
jid = current_tab.jid.bare
message = None
elif len(args) == 1:
- jid = safeJID(args[0]).domain
- if not jid:
+ try:
+ jid = JID(args[0]).domain
+ except InvalidJID:
return self.core.command_help('server_part')
message = None
else:
- jid = safeJID(args[0]).domain
- if not jid:
+ try:
+ jid = JID(args[0]).domain
+ except InvalidJID:
return self.core.command_help('server_part')
message = args[1]
diff --git a/plugins/uptime.py b/plugins/uptime.py
index eca89cc5..a55af970 100644
--- a/plugins/uptime.py
+++ b/plugins/uptime.py
@@ -12,7 +12,7 @@ Command
Retrieve the uptime of the server of ``jid``.
"""
from poezio.plugin import BasePlugin
-from poezio.common import parse_secs_to_str, safeJID
+from poezio.common import parse_secs_to_str
from slixmpp.xmlstream import ET
from slixmpp import JID, InvalidJID
from slixmpp.exceptions import IqError, IqTimeout