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.
This commit is contained in:
Clint Byrum
2015-05-23 17:50:46 -07:00
parent bca9862efd
commit 3259e58bee

View File

@@ -166,9 +166,10 @@ def make_soap_enveloped_saml_thingy(thingy, header_parts=None):
if isinstance(thingy, six.string_types):
# remove the first XML version/encoding line
logger.debug("thingy0: %s" % thingy)
_part = thingy.split("\n")
thingy = "".join(_part[1:])
if thingy[0:5].lower() == '<?xml':
logger.debug("thingy0: %s" % thingy)
_part = thingy.split("\n")
thingy = "".join(_part[1:])
thingy = thingy.replace(PREFIX, "")
logger.debug("thingy: %s" % thingy)
_child = ElementTree.Element('')