sat_frontends (tools): force JID's node and domain to lower-case:
- this changeset should go with a modification of PRIVATE_PREFIX, but the change has been already (accidentally) pushed with the previous changeset
This commit is contained in:
parent
987cfbf89d
commit
0443149ef8
1 changed files with 15 additions and 4 deletions
|
|
@ -22,12 +22,21 @@ class JID(unicode):
|
|||
"""This class help manage JID (Node@Domaine/Resource)"""
|
||||
|
||||
def __new__(cls, jid):
|
||||
self = unicode.__new__(cls, jid)
|
||||
self = unicode.__new__(cls, cls.__normalize(jid))
|
||||
self.__parse()
|
||||
return self
|
||||
|
||||
@classmethod
|
||||
def __normalize(cls, jid):
|
||||
"""Naive normalization before instantiating and parsing the JID"""
|
||||
if not jid:
|
||||
return jid
|
||||
tokens = jid.split('/')
|
||||
tokens[0] = tokens[0].lower() # force node and domain to lower-case
|
||||
return '/'.join(tokens)
|
||||
|
||||
def __parse(self):
|
||||
"""find node domain and resource"""
|
||||
"""Find node domain and resource"""
|
||||
node_end = self.find('@')
|
||||
if node_end < 0:
|
||||
node_end = 0
|
||||
|
|
@ -43,6 +52,8 @@ class JID(unicode):
|
|||
self.bare = self.node + '@' + self.domain
|
||||
|
||||
def is_valid(self):
|
||||
"""return True if the jid is xmpp compliant"""
|
||||
#TODO: implement real check, according to RFCs
|
||||
"""
|
||||
@return: True if the JID is XMPP compliant
|
||||
"""
|
||||
# TODO: implement real check, according to the RFC http://tools.ietf.org/html/rfc6122
|
||||
return self.domain != ""
|
||||
|
|
|
|||
Loading…
Reference in a new issue