Do not generate invalid jids (e.g. localpart@domainpart/)

This is in prevision of a sleekxmpp update with JID validation.
Also, comment the “server” option in the config file a bit better.
This commit is contained in:
mathieui 2012-08-01 20:10:00 +02:00
parent f76e80c5fa
commit 0cb39b32a4
3 changed files with 9 additions and 4 deletions

View file

@ -4,7 +4,8 @@
[Poezio]
# the server. Make sure the server you're using accepts anonymous authentification
# The server used for anonymous connection.
# Make sure the server you're using accepts anonymous authentication
server = anon.louiz.org
# SSL Certificate fingerprint

View file

@ -34,7 +34,9 @@ class Connection(sleekxmpp.ClientXMPP):
self.anon = False # Field used to know if we are anonymous or not.
# many features will be handled diferently
# depending on this setting
jid = '%s/%s' % (config.get('jid', ''), resource)
jid = '%s' % config.get('jid', '')
if resource:
jid = '%s/%s' (jid, resource)
password = config.get('password', '') or getpass.getpass()
else: # anonymous auth
self.anon = True

View file

@ -100,8 +100,10 @@ class Contact(object):
@property
def resources(self):
"""List of the available resources as Resource objects"""
return [Resource('%s/%s' % (self.bare_jid, key), self.__item.resources[key])
for key in self.__item.resources]
return [Resource(
'%s%s' % (self.bare_jid, ('/' + key) if key else ''),
self.__item.resources[key]
) for key in self.__item.resources.keys()]
@property
def subscription(self):