Skip to content

Commit cd6030d

Browse files
committed
Fix the parser to not break on ePTID AttributeValues
Signed-off-by: Ivan Kanakarakis <ivan.kanak@gmail.com>
1 parent 8dcb31b commit cd6030d

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

src/saml2/saml.py

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ def __setattr__(self, key, value):
115115
SamlBase.__setattr__(self, key, value)
116116

117117
def verify(self):
118-
if not self.text:
118+
if not self.text and not self.extension_elements:
119119
if not self.extension_attributes:
120120
raise Exception(
121121
"Attribute value base should not have extension attributes"
@@ -293,11 +293,26 @@ def harvest_element_tree(self, tree):
293293
self._convert_element_tree_to_member(child)
294294
for attribute, value in iter(tree.attrib.items()):
295295
self._convert_element_attribute_to_member(attribute, value)
296-
if tree.text:
296+
297+
# if we have added children to this node
298+
# we consider whitespace insignificant
299+
# and remove/trim/strip whitespace
300+
# and expect to not have actual text content
301+
text = (
302+
tree.text.strip()
303+
if tree.text and self.extension_elements
304+
else tree.text
305+
)
306+
if text:
297307
#print("set_text:", tree.text)
298308
# clear type
299309
#self.clear_type()
300-
self.set_text(tree.text)
310+
self.set_text(text)
311+
312+
# if we have added a text node
313+
# or other children to this node
314+
# remove the nil marker
315+
if text or self.extension_elements:
301316
if XSI_NIL in self.extension_attributes:
302317
del self.extension_attributes[XSI_NIL]
303318

0 commit comments

Comments
 (0)