File 0003-Fix-the-parser-to-not-break-on-ePTID-AttributeValues.patch of Package python-pysaml2

From 955cf7eb55ae9ce43d21282b976f84e04220f324 Mon Sep 17 00:00:00 2001
From: Ivan Kanakarakis <ivan.kanak@gmail.com>
Date: Fri, 15 Jan 2021 15:09:58 +0200
Subject: [PATCH 3/7] Fix the parser to not break on ePTID AttributeValues

Conflicts:
	src/saml2/saml.py

Signed-off-by: Ivan Kanakarakis <ivan.kanak@gmail.com>
(cherry picked from commit cd6030d79e23d2421ff8b8bcbebb9632bc4caedc)
---
 src/saml2/saml.py | 21 ++++++++++++++++++---
 1 file changed, 18 insertions(+), 3 deletions(-)

diff --git a/src/saml2/saml.py b/src/saml2/saml.py
index c53aab95..f0f3cc6c 100644
--- a/src/saml2/saml.py
+++ b/src/saml2/saml.py
@@ -153,7 +153,7 @@ class AttributeValueBase(SamlBase):
             SamlBase.__setattr__(self, key, value)
 
     def verify(self):
-        if not self.text:
+        if not self.text and not self.extension_elements:
             assert self.extension_attributes
             assert self.extension_attributes[XSI_NIL] == "true"
             return True
@@ -267,11 +267,26 @@ class AttributeValueBase(SamlBase):
             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]
             try:
-- 
2.29.2

openSUSE Build Service is sponsored by