Skip to content

Commit

Permalink
Fix the parser to not break on ePTID AttributeValues
Browse files Browse the repository at this point in the history
Signed-off-by: Ivan Kanakarakis <[email protected]>
  • Loading branch information
c00kiemon5ter committed Jan 15, 2021
1 parent 8dcb31b commit cd6030d
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions src/saml2/saml.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ def __setattr__(self, key, value):
SamlBase.__setattr__(self, key, value)

def verify(self):
if not self.text:
if not self.text and not self.extension_elements:
if not self.extension_attributes:
raise Exception(
"Attribute value base should not have extension attributes"
Expand Down Expand Up @@ -293,11 +293,26 @@ def harvest_element_tree(self, tree):
self._convert_element_tree_to_member(child)
for attribute, value in iter(tree.attrib.items()):
self._convert_element_attribute_to_member(attribute, value)
if tree.text:

# if we have added children to this node
# we consider whitespace insignificant
# and remove/trim/strip whitespace
# and expect to not have actual text content
text = (
tree.text.strip()
if tree.text and self.extension_elements
else tree.text
)
if text:
#print("set_text:", tree.text)
# clear type
#self.clear_type()
self.set_text(tree.text)
self.set_text(text)

# if we have added a text node
# or other children to this node
# remove the nil marker
if text or self.extension_elements:
if XSI_NIL in self.extension_attributes:
del self.extension_attributes[XSI_NIL]

Expand Down

0 comments on commit cd6030d

Please sign in to comment.