xmlmask now ignores namespace on subdomains properly if ignore_ns is set

This commit is contained in:
Nathan Fritz 2009-07-11 20:34:27 +00:00
parent d9b812a73b
commit a280e3c140

View file

@ -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]