Skip to content

Commit 3259e58

Browse files
committed
Only remove xml header if it is present
In python3, etree won't add an XML header if the defaults would suffice. This fixes some python3-only test failures.
1 parent bca9862 commit 3259e58

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/saml2/pack.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -166,9 +166,10 @@ def make_soap_enveloped_saml_thingy(thingy, header_parts=None):
166166

167167
if isinstance(thingy, six.string_types):
168168
# remove the first XML version/encoding line
169-
logger.debug("thingy0: %s" % thingy)
170-
_part = thingy.split("\n")
171-
thingy = "".join(_part[1:])
169+
if thingy[0:5].lower() == '<?xml':
170+
logger.debug("thingy0: %s" % thingy)
171+
_part = thingy.split("\n")
172+
thingy = "".join(_part[1:])
172173
thingy = thingy.replace(PREFIX, "")
173174
logger.debug("thingy: %s" % thingy)
174175
_child = ElementTree.Element('')

0 commit comments

Comments
 (0)