# HG changeset patch # User souliane # Date 1409052792 -7200 # Node ID 7f32371568e4f54d8e37757aa758bc6241650564 # Parent 75025461141f7f1721bde599e9c651d06054b5fa 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 diff -r 75025461141f -r 7f32371568e4 frontends/src/tools/jid.py --- a/frontends/src/tools/jid.py Tue Aug 26 12:52:46 2014 +0200 +++ b/frontends/src/tools/jid.py Tue Aug 26 13:33:12 2014 +0200 @@ -22,12 +22,21 @@ """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 @@ 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 != ""