diff --git a/src/saml2/entity.py b/src/saml2/entity.py index 9d0d2dcfe..8016b4819 100644 --- a/src/saml2/entity.py +++ b/src/saml2/entity.py @@ -3,6 +3,7 @@ import copy from hashlib import sha1 import logging +import zlib import requests @@ -444,7 +445,10 @@ def unravel(txt, binding, msgtype="response"): if binding == BINDING_HTTP_REDIRECT: xmlstr = decode_base64_and_inflate(txt) elif binding == BINDING_HTTP_POST: - xmlstr = base64.b64decode(txt) + try: + xmlstr = decode_base64_and_inflate(txt) + except zlib.error: + xmlstr = base64.b64decode(txt) elif binding == BINDING_SOAP: func = getattr(soap, f"parse_soap_enveloped_saml_{msgtype}") xmlstr = func(txt)