handle jid errors
This commit is contained in:
parent
676bda8281
commit
016ccb74b1
|
@ -758,7 +758,7 @@ class ConnectionDisco:
|
||||||
if 'jid' not in attr:
|
if 'jid' not in attr:
|
||||||
continue
|
continue
|
||||||
try:
|
try:
|
||||||
helpers.parse_jid(attr['jid'])
|
attr['jid'] = helpers.parse_jid(attr['jid'])
|
||||||
except common.helpers.InvalidFormat:
|
except common.helpers.InvalidFormat:
|
||||||
# jid is not conform
|
# jid is not conform
|
||||||
continue
|
continue
|
||||||
|
@ -1150,7 +1150,10 @@ class ConnectionVcard:
|
||||||
storage = query.getTag('storage')
|
storage = query.getTag('storage')
|
||||||
metas = storage.getTags('meta')
|
metas = storage.getTags('meta')
|
||||||
for meta in metas:
|
for meta in metas:
|
||||||
|
try:
|
||||||
jid = helpers.parse_jid(meta.getAttr('jid'))
|
jid = helpers.parse_jid(meta.getAttr('jid'))
|
||||||
|
except common.helpers.InvalidFormat:
|
||||||
|
continue
|
||||||
tag = meta.getAttr('tag')
|
tag = meta.getAttr('tag')
|
||||||
data = {'jid': jid}
|
data = {'jid': jid}
|
||||||
order = meta.getAttr('order')
|
order = meta.getAttr('order')
|
||||||
|
@ -1518,6 +1521,7 @@ class ConnectionHandlers(ConnectionVcard, ConnectionBytestream, ConnectionDisco,
|
||||||
print_status = conf.getTagData('print_status')
|
print_status = conf.getTagData('print_status')
|
||||||
if not print_status:
|
if not print_status:
|
||||||
print_status = conf.getTagData('show_status')
|
print_status = conf.getTagData('show_status')
|
||||||
|
try:
|
||||||
bm = {'name': conf.getAttr('name'),
|
bm = {'name': conf.getAttr('name'),
|
||||||
'jid': helpers.parse_jid(conf.getAttr('jid')),
|
'jid': helpers.parse_jid(conf.getAttr('jid')),
|
||||||
'autojoin': autojoin_val,
|
'autojoin': autojoin_val,
|
||||||
|
@ -1525,6 +1529,9 @@ class ConnectionHandlers(ConnectionVcard, ConnectionBytestream, ConnectionDisco,
|
||||||
'password': conf.getTagData('password'),
|
'password': conf.getTagData('password'),
|
||||||
'nick': conf.getTagData('nick'),
|
'nick': conf.getTagData('nick'),
|
||||||
'print_status': print_status}
|
'print_status': print_status}
|
||||||
|
except common.helpers.InvalidFormat:
|
||||||
|
log.warn('Invalid JID: %s, ignoring it' % conf.getAttr('jid'))
|
||||||
|
continue
|
||||||
|
|
||||||
self.bookmarks.append(bm)
|
self.bookmarks.append(bm)
|
||||||
self.dispatch('BOOKMARKS', self.bookmarks)
|
self.dispatch('BOOKMARKS', self.bookmarks)
|
||||||
|
@ -1539,14 +1546,22 @@ class ConnectionHandlers(ConnectionVcard, ConnectionBytestream, ConnectionDisco,
|
||||||
# http://www.xmpp.org/extensions/xep-0145.html
|
# http://www.xmpp.org/extensions/xep-0145.html
|
||||||
notes = storage.getTags('note')
|
notes = storage.getTags('note')
|
||||||
for note in notes:
|
for note in notes:
|
||||||
|
try:
|
||||||
jid = helpers.parse_jid(note.getAttr('jid'))
|
jid = helpers.parse_jid(note.getAttr('jid'))
|
||||||
|
except common.helpers.InvalidFormat:
|
||||||
|
log.warn('Invalid JID: %s, ignoring it' % note.getAttr('jid'))
|
||||||
|
continue
|
||||||
annotation = note.getData()
|
annotation = note.getData()
|
||||||
self.annotations[jid] = annotation
|
self.annotations[jid] = annotation
|
||||||
|
|
||||||
def _rosterSetCB(self, con, iq_obj):
|
def _rosterSetCB(self, con, iq_obj):
|
||||||
log.debug('rosterSetCB')
|
log.debug('rosterSetCB')
|
||||||
for item in iq_obj.getTag('query').getChildren():
|
for item in iq_obj.getTag('query').getChildren():
|
||||||
|
try:
|
||||||
jid = helpers.parse_jid(item.getAttr('jid'))
|
jid = helpers.parse_jid(item.getAttr('jid'))
|
||||||
|
except common.helpers.InvalidFormat:
|
||||||
|
log.warn('Invalid JID: %s, ignoring it' % item.getAttr('jid'))
|
||||||
|
continue
|
||||||
name = item.getAttr('name')
|
name = item.getAttr('name')
|
||||||
sub = item.getAttr('subscription')
|
sub = item.getAttr('subscription')
|
||||||
ask = item.getAttr('ask')
|
ask = item.getAttr('ask')
|
||||||
|
@ -1785,7 +1800,11 @@ class ConnectionHandlers(ConnectionVcard, ConnectionBytestream, ConnectionDisco,
|
||||||
action = 'add'
|
action = 'add'
|
||||||
for item in msg.getTag('x',
|
for item in msg.getTag('x',
|
||||||
namespace=common.xmpp.NS_ROSTERX).getChildren():
|
namespace=common.xmpp.NS_ROSTERX).getChildren():
|
||||||
|
try:
|
||||||
jid = helpers.parse_jid(item.getAttr('jid'))
|
jid = helpers.parse_jid(item.getAttr('jid'))
|
||||||
|
except common.helpers.InvalidFormat:
|
||||||
|
log.warn('Invalid JID: %s, ignoring it' % item.getAttr('jid'))
|
||||||
|
continue
|
||||||
name = item.getAttr('name')
|
name = item.getAttr('name')
|
||||||
groups=[]
|
groups=[]
|
||||||
for group in item.getTags('group'):
|
for group in item.getTags('group'):
|
||||||
|
@ -1832,7 +1851,11 @@ class ConnectionHandlers(ConnectionVcard, ConnectionBytestream, ConnectionDisco,
|
||||||
if addressTag and jid == gajim.get_jid_from_account(self.name):
|
if addressTag and jid == gajim.get_jid_from_account(self.name):
|
||||||
address = addressTag.getTag('address', attrs={'type': 'ofrom'})
|
address = addressTag.getTag('address', attrs={'type': 'ofrom'})
|
||||||
if address:
|
if address:
|
||||||
|
try:
|
||||||
frm = helpers.parse_jid(address.getAttr('jid'))
|
frm = helpers.parse_jid(address.getAttr('jid'))
|
||||||
|
except common.helpers.InvalidFormat:
|
||||||
|
log.warn('Invalid JID: %s, ignoring it' % address.getAttr('jid'))
|
||||||
|
return
|
||||||
jid = gajim.get_jid_without_resource(frm)
|
jid = gajim.get_jid_without_resource(frm)
|
||||||
|
|
||||||
# invitations
|
# invitations
|
||||||
|
@ -1850,7 +1873,11 @@ class ConnectionHandlers(ConnectionVcard, ConnectionBytestream, ConnectionDisco,
|
||||||
xtags = msg.getTags('x')
|
xtags = msg.getTags('x')
|
||||||
for xtag in xtags:
|
for xtag in xtags:
|
||||||
if xtag.getNamespace() == common.xmpp.NS_CONFERENCE and not invite:
|
if xtag.getNamespace() == common.xmpp.NS_CONFERENCE and not invite:
|
||||||
|
try:
|
||||||
room_jid = helpers.parse_jid(xtag.getAttr('jid'))
|
room_jid = helpers.parse_jid(xtag.getAttr('jid'))
|
||||||
|
except common.helpers.InvalidFormat:
|
||||||
|
log.warn('Invalid JID: %s, ignoring it' % xtag.getAttr('jid'))
|
||||||
|
continue
|
||||||
is_continued = False
|
is_continued = False
|
||||||
if xtag.getTag('continue'):
|
if xtag.getTag('continue'):
|
||||||
is_continued = True
|
is_continued = True
|
||||||
|
@ -2050,7 +2077,11 @@ class ConnectionHandlers(ConnectionVcard, ConnectionBytestream, ConnectionDisco,
|
||||||
|
|
||||||
def dispatch_invite_message(self, invite, frm):
|
def dispatch_invite_message(self, invite, frm):
|
||||||
item = invite.getTag('invite')
|
item = invite.getTag('invite')
|
||||||
|
try:
|
||||||
jid_from = helpers.parse_jid(item.getAttr('from'))
|
jid_from = helpers.parse_jid(item.getAttr('from'))
|
||||||
|
except common.helpers.InvalidFormat:
|
||||||
|
log.warn('Invalid JID: %s, ignoring it' % item.getAttr('from'))
|
||||||
|
return
|
||||||
reason = item.getTagData('reason')
|
reason = item.getTagData('reason')
|
||||||
item = invite.getTag('password')
|
item = invite.getTag('password')
|
||||||
password = invite.getTagData('password')
|
password = invite.getTagData('password')
|
||||||
|
@ -2254,7 +2285,10 @@ class ConnectionHandlers(ConnectionVcard, ConnectionBytestream, ConnectionDisco,
|
||||||
r = destroy.getTagData('reason')
|
r = destroy.getTagData('reason')
|
||||||
if r:
|
if r:
|
||||||
reason += ' (%s)' % r
|
reason += ' (%s)' % r
|
||||||
|
try:
|
||||||
jid = helpers.parse_jid(destroy.getAttr('jid'))
|
jid = helpers.parse_jid(destroy.getAttr('jid'))
|
||||||
|
except common.helpers.InvalidFormat:
|
||||||
|
pass
|
||||||
if jid:
|
if jid:
|
||||||
reason += '\n' + _('You can join this room instead: %s') % jid
|
reason += '\n' + _('You can join this room instead: %s') % jid
|
||||||
statusCode = ['destroyed']
|
statusCode = ['destroyed']
|
||||||
|
@ -2401,7 +2435,11 @@ class ConnectionHandlers(ConnectionVcard, ConnectionBytestream, ConnectionDisco,
|
||||||
users_dict = {}
|
users_dict = {}
|
||||||
for item in items:
|
for item in items:
|
||||||
if item.has_attr('jid') and item.has_attr('affiliation'):
|
if item.has_attr('jid') and item.has_attr('affiliation'):
|
||||||
|
try:
|
||||||
jid = helpers.parse_jid(item.getAttr('jid'))
|
jid = helpers.parse_jid(item.getAttr('jid'))
|
||||||
|
except common.helpers.InvalidFormat:
|
||||||
|
log.warn('Invalid JID: %s, ignoring it' % item.getAttr('jid'))
|
||||||
|
return
|
||||||
affiliation = item.getAttr('affiliation')
|
affiliation = item.getAttr('affiliation')
|
||||||
users_dict[jid] = {'affiliation': affiliation}
|
users_dict[jid] = {'affiliation': affiliation}
|
||||||
if item.has_attr('nick'):
|
if item.has_attr('nick'):
|
||||||
|
|
Loading…
Reference in New Issue