Skip to content

Commit

Permalink
Merge pull request #348 from j3hyde/master
Browse files Browse the repository at this point in the history
Fixes xmlsec output line parsing on CRLF platforms (e.g. Windows).
  • Loading branch information
rohe committed Aug 1, 2016
2 parents 9617003 + 43f84cd commit fd7a4f6
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/saml2/algsupport.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def get_algorithm_support(xmlsec):
pof.wait()

if not p_err:
p = p_out.split('\n')
p = p_out.splitlines()
algs = [x.strip('"') for x in p[1].split(',')]
digest = []
signing = []
Expand Down
2 changes: 1 addition & 1 deletion src/saml2/sigver.py
Original file line number Diff line number Diff line change
Expand Up @@ -586,7 +586,7 @@ def parse_xmlsec_output(output):
:param output: The output from Popen
:return: A boolean; True if the command was a success otherwise False
"""
for line in output.split("\n"):
for line in output.splitlines():
if line == "OK":
return True
elif line == "FAIL":
Expand Down
13 changes: 13 additions & 0 deletions tests/test_40_sigver.py
Original file line number Diff line number Diff line change
Expand Up @@ -540,6 +540,19 @@ def test_sha256_signing():
assert s


def test_xmlsec_output_line_parsing():
output1 = "prefix\nOK\npostfix"
assert sigver.parse_xmlsec_output(output1)

output2 = "prefix\nFAIL\npostfix"
raises(sigver.XmlsecError, sigver.parse_xmlsec_output, output2)

output3 = "prefix\r\nOK\r\npostfix"
assert sigver.parse_xmlsec_output(output3)

output4 = "prefix\r\nFAIL\r\npostfix"
raises(sigver.XmlsecError, sigver.parse_xmlsec_output, output4)


if __name__ == "__main__":
# t = TestSecurity()
Expand Down

0 comments on commit fd7a4f6

Please sign in to comment.