do not allow to join a malformed room (abc/def@server.org). fixes #2520.
This commit is contained in:
parent
9694f931bf
commit
c69061b41c
|
@ -44,11 +44,7 @@ special_groups = (_('Transports'), _('Not in Roster'), _('Observers'))
|
|||
class InvalidFormat(Exception):
|
||||
pass
|
||||
|
||||
def parse_jid(jidstring):
|
||||
'''Perform stringprep on all JID fragments from a string
|
||||
and return the full jid'''
|
||||
# This function comes from http://svn.twistedmatrix.com/cvs/trunk/twisted/words/protocols/jabber/jid.py
|
||||
|
||||
def decompose_jid(jidstring):
|
||||
user = None
|
||||
server = None
|
||||
resource = None
|
||||
|
@ -80,8 +76,14 @@ def parse_jid(jidstring):
|
|||
# server/resource (with an @ in resource)
|
||||
server = jidstring[0:res_sep]
|
||||
resource = jidstring[res_sep + 1:] or None
|
||||
return user, server, resource
|
||||
|
||||
return prep(user, server, resource)
|
||||
def parse_jid(jidstring):
|
||||
'''Perform stringprep on all JID fragments from a string
|
||||
and return the full jid'''
|
||||
# This function comes from http://svn.twistedmatrix.com/cvs/trunk/twisted/words/protocols/jabber/jid.py
|
||||
|
||||
return prep(*decompose_jid(jidstring))
|
||||
|
||||
def parse_resource(resource):
|
||||
'''Perform stringprep on resource and return it'''
|
||||
|
|
|
@ -1207,6 +1207,11 @@ class JoinGroupchatWindow:
|
|||
room_jid = self._room_jid_entry.get_text().decode('utf-8')
|
||||
password = self.xml.get_widget('password_entry').get_text().decode(
|
||||
'utf-8')
|
||||
user, server, resource = helpers.decompose_jid(room_jid)
|
||||
if not user or not server or resource:
|
||||
ErrorDialog(_('Invalid group chat Jabber ID'),
|
||||
_('The group chat Jabber ID has not allowed characters.'))
|
||||
return
|
||||
try:
|
||||
room_jid = helpers.parse_jid(room_jid)
|
||||
except:
|
||||
|
|
Loading…
Reference in New Issue