Skip to content

Commit

Permalink
Merge pull request #17 from Fabma/allow_binary_data_as2_msg
Browse files Browse the repository at this point in the history
Dont replace "\n" newlines in application/octet-stream payload with "…
  • Loading branch information
abhishek-ram authored May 12, 2020
2 parents 29e1190 + 1beb1ed commit b4e65f4
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
3 changes: 1 addition & 2 deletions pyas2lib/tests/test_advanced.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,8 @@ def test_binary_message(self):
)

# Compare the mic contents of the input and output messages
# self.assertEqual(original_message,
# in_message.payload.get_payload(decode=True))
self.assertEqual(status, "processed")
self.assertEqual(original_message, in_message.payload.get_payload(decode=True))
self.assertTrue(in_message.signed)
self.assertTrue(in_message.encrypted)
self.assertEqual(out_message.mic, in_message.mic)
Expand Down
10 changes: 4 additions & 6 deletions pyas2lib/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,10 @@ def _handle_text(self, msg):
Handle writing the binary messages to prevent default behaviour of
newline replacements.
"""
if msg.get(
"Content-Transfer-Encoding"
) == "binary" and msg.get_content_subtype() in [
"pkcs7-mime",
"pkcs7-signature",
]:
if msg.get_content_type() == "application/octet-stream" or (
msg.get("Content-Transfer-Encoding") == "binary"
and msg.get_content_subtype() in ["pkcs7-mime", "pkcs7-signature",]
):
payload = msg.get_payload(decode=True)
if payload is None:
return
Expand Down

0 comments on commit b4e65f4

Please sign in to comment.