Skip to content

Commit f9518a7

Browse files
committed
unravel: raise error or continue the happy flow
Signed-off-by: Ivan Kanakarakis <[email protected]>
1 parent 3fc608a commit f9518a7

File tree

1 file changed

+16
-16
lines changed

1 file changed

+16
-16
lines changed

src/saml2/entity.py

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -440,24 +440,24 @@ def unravel(txt, binding, msgtype="response"):
440440
None,
441441
]:
442442
raise UnknownBinding(f"Don't know how to handle '{binding}'")
443-
else:
444-
try:
445-
if binding == BINDING_HTTP_REDIRECT:
443+
444+
try:
445+
if binding == BINDING_HTTP_REDIRECT:
446+
xmlstr = decode_base64_and_inflate(txt)
447+
elif binding == BINDING_HTTP_POST:
448+
try:
446449
xmlstr = decode_base64_and_inflate(txt)
447-
elif binding == BINDING_HTTP_POST:
448-
try:
449-
xmlstr = decode_base64_and_inflate(txt)
450-
except zlib.error:
451-
xmlstr = base64.b64decode(txt)
452-
elif binding == BINDING_SOAP:
453-
func = getattr(soap, f"parse_soap_enveloped_saml_{msgtype}")
454-
xmlstr = func(txt)
455-
elif binding == BINDING_HTTP_ARTIFACT:
450+
except zlib.error:
456451
xmlstr = base64.b64decode(txt)
457-
else:
458-
xmlstr = txt
459-
except Exception:
460-
raise UnravelError(f"Unravelling binding '{binding}' failed")
452+
elif binding == BINDING_SOAP:
453+
func = getattr(soap, f"parse_soap_enveloped_saml_{msgtype}")
454+
xmlstr = func(txt)
455+
elif binding == BINDING_HTTP_ARTIFACT:
456+
xmlstr = base64.b64decode(txt)
457+
else:
458+
xmlstr = txt
459+
except Exception:
460+
raise UnravelError(f"Unravelling binding '{binding}' failed")
461461

462462
return xmlstr
463463

0 commit comments

Comments
 (0)