fix looking for a type in an XSD with recursive type definition

Fixes an infinite recursion bug encountered when looking for an XSD type in an
XSD schema that does not contain it but itself defines a type referencing a
recursively defined type from an imported XSD schema. Kudos to Kevin Pors
(krpors on BitBucket) for detecting, analysing & reporting the issue, plus
preparing a working quick-fix.

Updated README.rst.
This commit is contained in:
Jurko Gospodnetić 2015-07-26 15:05:08 +02:00
parent befa968f28
commit a45a9428f5
2 changed files with 56 additions and 5 deletions

View File

@ -164,6 +164,13 @@ version 0.7 (development)
* Fixed loading recursive WSDL imports.
* Fixed loading recursive XSD imports/includes.
* Fixed an infinite recursion bug encountered when looking for an XSD type in an
XSD schema that does not contain it but itself defines a type referencing a
recursively defined type from an imported XSD schema.
* Kudos to Kevin Pors (`krpors` on BitBucket) for detecting, analysing &
reporting the issue, plus preparing a working quick-fix.
* Made ``suds`` no longer eat up, log & ignore exceptions raised from registered
user plugins (detected & reported by Ezequiel Ruiz & Bouke Haarsma, patch &
test case contributed by Bouke Haarsma).
@ -543,6 +550,9 @@ version 0.6 (2014-01-24)
considered unqualified.
* Loading recursive WSDL imports is broken.
* Loading recursive XSD imports/includes is broken.
* Infinite recursion bug encountered when looking for an XSD type in an XSD
schema that does not contain it but itself defines a type referencing a
recursively defined type from an imported XSD schema.
version 0.5 (2013-11-25)
------------------------
@ -610,6 +620,9 @@ version 0.5 (2013-11-25)
considered unqualified.
* Loading recursive WSDL imports is broken.
* Loading recursive XSD imports/includes is broken.
* Infinite recursion bug encountered when looking for an XSD type in an XSD
schema that does not contain it but itself defines a type referencing a
recursively defined type from an imported XSD schema.
version 0.4.1 jurko 5 (2013-11-11)
----------------------------------
@ -766,6 +779,9 @@ version 0.4.1 jurko 5 (2013-11-11)
considered unqualified.
* Loading recursive WSDL imports is broken.
* Loading recursive XSD imports/includes is broken.
* Infinite recursion bug encountered when looking for an XSD type in an XSD
schema that does not contain it but itself defines a type referencing a
recursively defined type from an imported XSD schema.
version 0.4.1 jurko 4 (2012-04-17)
----------------------------------
@ -808,6 +824,9 @@ version 0.4.1 jurko 4 (2012-04-17)
considered unqualified.
* Loading recursive WSDL imports is broken.
* Loading recursive XSD imports/includes is broken.
* Infinite recursion bug encountered when looking for an XSD type in an XSD
schema that does not contain it but itself defines a type referencing a
recursively defined type from an imported XSD schema.
version 0.4.1 jurko 3 (2011-12-26)
----------------------------------
@ -851,6 +870,9 @@ version 0.4.1 jurko 3 (2011-12-26)
considered unqualified.
* Loading recursive WSDL imports is broken.
* Loading recursive XSD imports/includes is broken.
* Infinite recursion bug encountered when looking for an XSD type in an XSD
schema that does not contain it but itself defines a type referencing a
recursively defined type from an imported XSD schema.
version 0.4.1 jurko 2 (2011-12-24)
----------------------------------
@ -893,6 +915,9 @@ version 0.4.1 jurko 2 (2011-12-24)
considered unqualified.
* Loading recursive WSDL imports is broken.
* Loading recursive XSD imports/includes is broken.
* Infinite recursion bug encountered when looking for an XSD type in an XSD
schema that does not contain it but itself defines a type referencing a
recursively defined type from an imported XSD schema.
version 0.4.1 jurko 1 (2011-12-24)
----------------------------------
@ -979,6 +1004,9 @@ version 0.4.1 jurko 1 (2011-12-24)
considered unqualified.
* Loading recursive WSDL imports is broken.
* Loading recursive XSD imports/includes is broken.
* Infinite recursion bug encountered when looking for an XSD type in an XSD
schema that does not contain it but itself defines a type referencing a
recursively defined type from an imported XSD schema.
Original suds library release notes
@ -989,7 +1017,18 @@ Original suds library release notes
* <undocumented>
* Known defects.
* SOAP request parameter XML elements constructed in incorrect namespaces in
case they have been defined by XSD schema elements referencing XSD schema
elements with a different target namespace.
* Security issue CVE-2013-2217 - using fixed default cache location.
* Incorrect referencing XSD element's ``form`` attribute value handling -
global XSD elements (i.e. top-level + reference elements) sometimes
considered unqualified.
* Loading recursive WSDL imports is broken.
* Loading recursive XSD imports/includes is broken.
* Infinite recursion bug encountered when looking for an XSD type in an XSD
schema that does not contain it but itself defines a type referencing a
recursively defined type from an imported XSD schema.
**version 0.4 (2010-09-08)**

View File

@ -339,14 +339,21 @@ class SchemaObject(UnicodeMixin):
"""Get whether the object has I{mixed} content."""
return False
def find(self, qref, classes=()):
def find(self, qref, classes=[], ignore=None):
"""
Find a referenced type in self or children.
Find a referenced type in self or children. Return None if not found.
Qualified references for all schema objects checked in this search will
be added to the set of ignored qualified references to avoid the find
operation going into an infinite loop in case of recursively defined
structures.
@param qref: A qualified reference.
@type qref: qref
@param classes: A list of classes used to qualify the match.
@type classes: [I{class},...]
@param classes: A collection of classes used to qualify the match.
@type classes: Collection(I{class},...), e.g. [I(class),...]
@param ignore: A set of qualified references to ignore in this search.
@type ignore: {qref,...}
@return: The referenced type.
@rtype: L{SchemaObject}
@see: L{qualify()}
@ -354,10 +361,15 @@ class SchemaObject(UnicodeMixin):
"""
if not len(classes):
classes = (self.__class__,)
if ignore is None:
ignore = set()
if self.qname in ignore:
return
ignore.add(self.qname)
if self.qname == qref and self.__class__ in classes:
return self
for c in self.rawchildren:
p = c.find(qref, classes)
p = c.find(qref, classes, ignore=ignore)
if p is not None:
return p