diff --git a/src/common/helpers.py b/src/common/helpers.py index b37aad73eecaf386fe6d7e1862dfeb5a90a3e7cd..52f9ac0e3b7c28dd5be79357d93b343dbaaf4154 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 e06111af393ba1814ad9502dcd386b017d6921d6..010ad98da2621d6adc4ee03469841247bccdb67e 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: