From c69061b41c5b4a69b23f6ae320a1e9881fa50493 Mon Sep 17 00:00:00 2001 From: Yann Leboulanger <asterix@lagaule.org> Date: Wed, 22 Nov 2006 23:21:33 +0000 Subject: [PATCH] do not allow to join a malformed room (abc/def@server.org). fixes #2520. --- src/common/helpers.py | 14 ++++++++------ src/dialogs.py | 5 +++++ 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/src/common/helpers.py b/src/common/helpers.py index b37aad73ee..52f9ac0e3b 100644 --- a/src/common/helpers.py +++ b/src/common/helpers.py @@ -44,11 +44,7 @@ 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 + +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(user, server, resource) + return prep(*decompose_jid(jidstring)) def parse_resource(resource): '''Perform stringprep on resource and return it''' diff --git a/src/dialogs.py b/src/dialogs.py index e06111af39..010ad98da2 100644 --- a/src/dialogs.py +++ b/src/dialogs.py @@ -1207,6 +1207,11 @@ def on_join_button_clicked(self, widget): 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: -- GitLab