filtermail: strip any empty lines at the end (#496)

This commit is contained in:
missytake
2025-02-19 16:38:01 +01:00
committed by GitHub
parent f4e371676b
commit c3f1bdca52
3 changed files with 16 additions and 1 deletions

View File

@@ -2,6 +2,9 @@
## untagged ## untagged
- filtermail: don't require exactly 2 lines after openPGP payload
([#497](https://github.com/chatmail/chatmail/pull/497))
- cmdeploy dns: offer alternative DKIM record format for some web interfaces - cmdeploy dns: offer alternative DKIM record format for some web interfaces
([#470](https://github.com/deltachat/chatmail/pull/470)) ([#470](https://github.com/deltachat/chatmail/pull/470))

View File

@@ -80,7 +80,9 @@ def check_armored_payload(payload: str):
return False return False
payload = payload.removeprefix(prefix) payload = payload.removeprefix(prefix)
suffix = "-----END PGP MESSAGE-----\r\n\r\n" while payload.endswith("\r\n"):
payload = payload.removesuffix("\r\n")
suffix = "-----END PGP MESSAGE-----"
if not payload.endswith(suffix): if not payload.endswith(suffix):
return False return False
payload = payload.removesuffix(suffix) payload = payload.removesuffix(suffix)

View File

@@ -205,10 +205,20 @@ UN4fiB0KR9JyG2ayUdNJVkXZSZLnHyRgiaadlpUo16LVvw==\r
=b5Kp\r =b5Kp\r
-----END PGP MESSAGE-----\r -----END PGP MESSAGE-----\r
\r \r
\r
""" """
assert check_armored_payload(payload) == True assert check_armored_payload(payload) == True
payload = payload.removesuffix("\r\n")
assert check_armored_payload(payload) == True
payload = payload.removesuffix("\r\n")
assert check_armored_payload(payload) == True
payload = payload.removesuffix("\r\n")
assert check_armored_payload(payload) == True
payload = """-----BEGIN PGP MESSAGE-----\r payload = """-----BEGIN PGP MESSAGE-----\r
\r \r
HELLOWORLD HELLOWORLD