Commits

Christian Heimes committed c565a8b

handle lxml's getiterator and itersiblings

Comments (0)

Files changed (1)

defusedxml/lxml.py

         iterator = super(RestrictedElement, self).iterdescendants(tag=tag, *tags)
         return self._filter(iterator)
 
+    def itersiblings(self, tag=None, preceding=False):
+        iterator = super(RestrictedElement, self).itersiblings(tag=tag, preceding=preceding)
+        return self._filter(iterator)
+
     def getchildren(self):
         iterator = super(RestrictedElement, self).__iter__()
         return list(self._filter(iterator))
 
+    def getiterator(self, tag=None):
+        iterator = super(RestrictedElement, self).getiterator(tag)
+        return self._filter(iterator)
+
 
 class GlobalParserTLS(threading.local):
     """Thread local context for custom parser instances
 
     def createDefaultParser(self):
         parser = _etree.XMLParser(**self.parser_config)
+        element_class = self.element_class
         if self.element_class is not None:
-            lookup = _etree.ElementDefaultClassLookup(element=RestrictedElement)
+            lookup = _etree.ElementDefaultClassLookup(element=element_class)
             parser.set_element_class_lookup(lookup)
         return parser