From a280e3c1405f55dfd372337f5d377212ed717833 Mon Sep 17 00:00:00 2001 From: Nathan Fritz Date: Sat, 11 Jul 2009 20:34:27 +0000 Subject: [PATCH] xmlmask now ignores namespace on subdomains properly if ignore_ns is set --- sleekxmpp/xmlstream/matcher/xmlmask.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/sleekxmpp/xmlstream/matcher/xmlmask.py b/sleekxmpp/xmlstream/matcher/xmlmask.py index 30cb13b..a161048 100644 --- a/sleekxmpp/xmlstream/matcher/xmlmask.py +++ b/sleekxmpp/xmlstream/matcher/xmlmask.py @@ -41,6 +41,18 @@ class MatchXMLMask(base.MatcherBase): return False #for subelement in maskobj.getiterator()[1:]: #recursively compare subelements for subelement in maskobj: #recursively compare subelements - if not self.maskcmp(source.find(subelement.tag), subelement, use_ns): - return False + if use_ns: + if not self.maskcmp(source.find(subelement.tag), subelement, use_ns): + return False + else: + if not self.maskcmp(self.getChildIgnoreNS(source, subelement.tag), subelement, use_ns): + return False return True + + def getChildIgnoreNS(self, xml, tag): + tag = tag.split('}')[-1] + try: + idx = [c.tag.split('}')[-1] for c in xml.getchildren()].index(tag) + except ValueError: + return None + return xml.getchildren()[idx]