Skip to content

Commit fd7a4f6

Browse files
authored
Merge pull request #348 from j3hyde/master
Fixes xmlsec output line parsing on CRLF platforms (e.g. Windows).
2 parents 9617003 + 43f84cd commit fd7a4f6

File tree

3 files changed

+15
-2
lines changed

3 files changed

+15
-2
lines changed

src/saml2/algsupport.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ def get_algorithm_support(xmlsec):
4242
pof.wait()
4343

4444
if not p_err:
45-
p = p_out.split('\n')
45+
p = p_out.splitlines()
4646
algs = [x.strip('"') for x in p[1].split(',')]
4747
digest = []
4848
signing = []

src/saml2/sigver.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -586,7 +586,7 @@ def parse_xmlsec_output(output):
586586
:param output: The output from Popen
587587
:return: A boolean; True if the command was a success otherwise False
588588
"""
589-
for line in output.split("\n"):
589+
for line in output.splitlines():
590590
if line == "OK":
591591
return True
592592
elif line == "FAIL":

tests/test_40_sigver.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -540,6 +540,19 @@ def test_sha256_signing():
540540
assert s
541541

542542

543+
def test_xmlsec_output_line_parsing():
544+
output1 = "prefix\nOK\npostfix"
545+
assert sigver.parse_xmlsec_output(output1)
546+
547+
output2 = "prefix\nFAIL\npostfix"
548+
raises(sigver.XmlsecError, sigver.parse_xmlsec_output, output2)
549+
550+
output3 = "prefix\r\nOK\r\npostfix"
551+
assert sigver.parse_xmlsec_output(output3)
552+
553+
output4 = "prefix\r\nFAIL\r\npostfix"
554+
raises(sigver.XmlsecError, sigver.parse_xmlsec_output, output4)
555+
543556

544557
if __name__ == "__main__":
545558
# t = TestSecurity()

0 commit comments

Comments
 (0)