do not allow to join a malformed room (abc/def@server.org). fixes #2520.
This commit is contained in:
parent
9694f931bf
commit
c69061b41c
2 changed files with 13 additions and 6 deletions
|
@ -44,11 +44,7 @@ special_groups = (_('Transports'), _('Not in Roster'), _('Observers'))
|
||||||
class InvalidFormat(Exception):
|
class InvalidFormat(Exception):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def parse_jid(jidstring):
|
def decompose_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
|
|
||||||
|
|
||||||
user = None
|
user = None
|
||||||
server = None
|
server = None
|
||||||
resource = None
|
resource = None
|
||||||
|
@ -80,8 +76,14 @@ def parse_jid(jidstring):
|
||||||
# server/resource (with an @ in resource)
|
# server/resource (with an @ in resource)
|
||||||
server = jidstring[0:res_sep]
|
server = jidstring[0:res_sep]
|
||||||
resource = jidstring[res_sep + 1:] or None
|
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):
|
def parse_resource(resource):
|
||||||
'''Perform stringprep on resource and return it'''
|
'''Perform stringprep on resource and return it'''
|
||||||
|
|
|
@ -1207,6 +1207,11 @@ class JoinGroupchatWindow:
|
||||||
room_jid = self._room_jid_entry.get_text().decode('utf-8')
|
room_jid = self._room_jid_entry.get_text().decode('utf-8')
|
||||||
password = self.xml.get_widget('password_entry').get_text().decode(
|
password = self.xml.get_widget('password_entry').get_text().decode(
|
||||||
'utf-8')
|
'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:
|
try:
|
||||||
room_jid = helpers.parse_jid(room_jid)
|
room_jid = helpers.parse_jid(room_jid)
|
||||||
except:
|
except:
|
||||||
|
|
Loading…
Add table
Reference in a new issue