summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authormathieui <mathieui@mathieui.net>2012-08-05 21:06:13 +0200
committermathieui <mathieui@mathieui.net>2012-08-05 21:06:13 +0200
commit5692a0278be231070a44d53aabb5daccad2a1ad6 (patch)
tree195a01ebd2929e6e81b2962fec98f4886dde8511 /src
parent8c0b3f8ae5ef6d61eefd9cdd9c6acec5a32fd7f9 (diff)
downloadpoezio-5692a0278be231070a44d53aabb5daccad2a1ad6.tar.gz
poezio-5692a0278be231070a44d53aabb5daccad2a1ad6.tar.bz2
poezio-5692a0278be231070a44d53aabb5daccad2a1ad6.tar.xz
poezio-5692a0278be231070a44d53aabb5daccad2a1ad6.zip
Should fix most tracebacks due to the new sleek version
(sleekxmpp added JID validation, which means that JID(something) now raises an exception if the jid is invalid, instead of failing silently and having JID('') as a default)
Diffstat (limited to 'src')
-rw-r--r--src/core.py45
-rw-r--r--src/tabs.py51
-rw-r--r--src/windows.py2
3 files changed, 75 insertions, 23 deletions
diff --git a/src/core.py b/src/core.py
index b06d0009..06f7f1cb 100644
--- a/src/core.py
+++ b/src/core.py
@@ -1365,7 +1365,10 @@ class Core(object):
if len(arg) > 1:
return self.command_help('list')
elif arg:
- server = JID(arg[0]).server
+ try:
+ server = JID(arg[0]).server
+ except InvalidJID:
+ server = JID('')
else:
if not isinstance(self.current_tab(), tabs.MucTab):
return self.information('Please provide a server', 'Error')
@@ -1400,7 +1403,10 @@ class Core(object):
args = common.shell_split(arg)
if len(args) < 1:
return self.command_help('version')
- jid = JID(args[0])
+ try:
+ jid = JID(args[0])
+ except InvalidJID:
+ jid = JID('')
if jid.resource or jid not in roster:
self.xmpp.plugin['xep_0092'].get_version(jid, callback=callback)
elif jid in roster:
@@ -1431,7 +1437,10 @@ class Core(object):
room = JID(tab.get_name()).bare
nick = tab.own_nick
else:
- info = JID(args[0])
+ try:
+ info = JID(args[0])
+ except InvalidJID:
+ info = JID('')
if info.resource == '':
default = os.environ.get('USER') if os.environ.get('USER') else 'poezio'
nick = config.get('default_nick', '')
@@ -1503,7 +1512,10 @@ class Core(object):
if len(txt.split()) != 2:
# we are not on the 1st argument of the command line
return False
- jid = JID(txt.split()[1])
+ try:
+ jid = JID(txt.split()[1])
+ except InvalidJID:
+ jid = JID('')
if jid.server:
if jid.resource or jid.full.endswith('/'):
# we are writing the resource: complete the node
@@ -1560,7 +1572,10 @@ class Core(object):
self.information('Bookmarks added and saved.', 'Info')
return
else:
- info = JID(args[0])
+ try:
+ info = JID(args[0])
+ except InvalidJID:
+ return self.information('Invalid JID.', 'Error')
if info.resource != '':
nick = info.resource
roomname = info.bare
@@ -1595,7 +1610,10 @@ class Core(object):
if len(args) == 1:
jid = JID('')
else:
- jid = JID(args[1])
+ try:
+ jid = JID(args[1])
+ except InvalidJID:
+ jid = JID('')
if len(args) > 2:
return
if jid.server and (jid.resource or jid.full.endswith('/')):
@@ -1655,7 +1673,10 @@ class Core(object):
self.information("Could not add the bookmarks.", "Info")
return
else:
- info = JID(args[0])
+ try:
+ info = JID(args[0])
+ except InvalidJID:
+ return self.information('Invalid JID.', 'Error')
if info.resource != '':
nick = info.resource
roomname = info.bare
@@ -1698,7 +1719,10 @@ class Core(object):
if len(args) == 1:
jid = JID('')
else:
- jid = JID(args[1])
+ try:
+ jid = JID(args[1])
+ except InvalidJID:
+ jid = JID('')
if len(args) == 2:
return the_input.auto_completion(['true', 'false'], '')
@@ -1937,7 +1961,10 @@ class Core(object):
args = common.shell_split(arg)
if not len(args):
return
- jid = JID(args[0])
+ try:
+ jid = JID(args[0])
+ except InvalidJID:
+ jid = JID('')
if jid.bare not in self.pending_invites:
return
reason = args[1] if len(args) > 1 else ''
diff --git a/src/tabs.py b/src/tabs.py
index 7bfc23d1..1cc924b8 100644
--- a/src/tabs.py
+++ b/src/tabs.py
@@ -807,7 +807,10 @@ class MucTab(ChatTab):
jid = JID(self.name)
jid.resource = arg
else:
- jid = JID(arg)
+ try:
+ jid = JID(arg)
+ except InvalidJID:
+ jid = JID('')
self.core.xmpp.plugin['xep_0092'].get_version(jid, callback=callback)
def command_nick(self, arg):
@@ -1910,8 +1913,7 @@ class RosterInfoTab(Tab):
try:
jid = JID(arg)
except InvalidJID:
- self.core.information('JID not well-formed', 'Error')
- return
+ jid = JID('')
elif isinstance(item, Contact):
jid = item.bare_jid
elif isinstance(item, Resource):
@@ -1940,8 +1942,7 @@ class RosterInfoTab(Tab):
try:
jid = JID(arg)
except InvalidJID:
- self.core.information('JID not well-formed', 'Error')
- return
+ jid = JID('')
elif isinstance(item, Contact):
jid = item.bare_jid
elif isinstance(item, Resource):
@@ -2061,7 +2062,10 @@ class RosterInfoTab(Tab):
self.core.information('No subscription to deny')
return
else:
- jid = JID(arg).bare
+ try:
+ jid = JID(arg).bare
+ except InvalidJID:
+ jid = JID('')
if not jid in [jid for jid in roster.jids()]:
self.core.information('No subscription to deny')
return
@@ -2075,7 +2079,10 @@ class RosterInfoTab(Tab):
Add the specified JID to the roster, and set automatically
accept the reverse subscription
"""
- jid = JID(JID(args.strip()).bare)
+ try:
+ jid = JID(JID(args.strip()).bare)
+ except InvalidJID:
+ return self.core.information('Invalid JID.', 'Error')
if not jid:
self.core.information(_('No JID specified'), 'Error')
return
@@ -2090,7 +2097,10 @@ class RosterInfoTab(Tab):
args = common.shell_split(arg)
if not args:
return self.core.command_help('name')
- jid = JID(args[0]).bare
+ try:
+ jid = JID(args[0]).bare
+ except InvalidJID:
+ jid = JID('')
name = args[1] if len(args) == 2 else ''
contact = roster[jid]
@@ -2110,7 +2120,10 @@ class RosterInfoTab(Tab):
args = common.shell_split(args)
if len(args) != 2:
return
- jid = JID(args[0]).bare
+ try:
+ jid = JID(args[0]).bare
+ except InvalidJID:
+ jid = JID('')
group = args[1]
contact = roster[jid]
@@ -2141,7 +2154,10 @@ class RosterInfoTab(Tab):
args = common.shell_split(arg)
if len(args) != 3:
return self.core.command_help('groupmove')
- jid = JID(args[0]).bare
+ try:
+ jid = JID(args[0]).bare
+ except InvalidJID:
+ jid = JID('')
group_from = args[1]
group_to = args[2]
@@ -2187,7 +2203,10 @@ class RosterInfoTab(Tab):
args = common.shell_split(args)
if len(args) != 2:
return
- jid = JID(args[0]).bare
+ try:
+ jid = JID(args[0]).bare
+ except InvalidJID:
+ jid = JID('')
group = args[1]
contact = roster[jid]
@@ -2216,7 +2235,10 @@ class RosterInfoTab(Tab):
from its presence, and cancel its subscription to our.
"""
if args.strip():
- jid = JID(args.strip()).bare
+ try:
+ jid = JID(args.strip()).bare
+ except InvalidJID:
+ jid = JID('')
else:
item = self.roster_win.selected_row
if isinstance(item, Contact):
@@ -2373,7 +2395,10 @@ class RosterInfoTab(Tab):
self.core.information('No subscription to accept')
return
else:
- jid = JID(arg).bare
+ try:
+ jid = JID(arg).bare
+ except InvalidJID:
+ jid = JID('')
contact = roster[jid]
if contact is None:
return
diff --git a/src/windows.py b/src/windows.py
index 4da0cff6..c2a77411 100644
--- a/src/windows.py
+++ b/src/windows.py
@@ -28,7 +28,7 @@ from contact import Contact
from roster import RosterGroup
from poopt import cut_text
-from sleekxmpp.xmlstream.stanzabase import JID
+from sleekxmpp import JID
import core
import wcwidth