diff options
| author | J08nY | 2017-06-26 19:14:57 +0200 |
|---|---|---|
| committer | J08nY | 2017-06-26 19:14:57 +0200 |
| commit | 13359343ef34c17473a0f2d9a8e7a67f748eb3c6 (patch) | |
| tree | 6a65346838ccc41e60d312b42618f5befc7e223b | |
| parent | 4cfe4ddec61e78ff4fe00cc9ce23ece5da357851 (diff) | |
| download | mailman-pgp-13359343ef34c17473a0f2d9a8e7a67f748eb3c6.tar.gz mailman-pgp-13359343ef34c17473a0f2d9a8e7a67f748eb3c6.tar.zst mailman-pgp-13359343ef34c17473a0f2d9a8e7a67f748eb3c6.zip | |
Add usual content headers to PGP/MIME signature body part.
- Enigmail sends them, so it should be good practice to do so too.
| -rw-r--r-- | src/mailman_pgp/pgp/mime.py | 14 | ||||
| -rw-r--r-- | src/mailman_pgp/pgp/utils.py | 2 |
2 files changed, 12 insertions, 4 deletions
diff --git a/src/mailman_pgp/pgp/mime.py b/src/mailman_pgp/pgp/mime.py index f3993a9..02306b4 100644 --- a/src/mailman_pgp/pgp/mime.py +++ b/src/mailman_pgp/pgp/mime.py @@ -99,7 +99,7 @@ class MIMEWrapper: def is_keys(self): for part in walk(self.msg): if (not part.is_multipart() - and part.get_content_type() != MIMEWrapper._keys_type): + and part.get_content_type() != MIMEWrapper._keys_type): return False return True @@ -112,7 +112,7 @@ class MIMEWrapper: """ for part in walk(self.msg): if (not part.is_multipart() - and part.get_content_type() == MIMEWrapper._keys_type): + and part.get_content_type() == MIMEWrapper._keys_type): return True return False @@ -124,7 +124,7 @@ class MIMEWrapper: """ for part in walk(self.msg): if (not part.is_multipart() - and part.get_content_type() == MIMEWrapper._keys_type): + and part.get_content_type() == MIMEWrapper._keys_type): key, _ = PGPKey.from_blob(part.get_payload()) yield key @@ -175,7 +175,13 @@ class MIMEWrapper: second_part = MIMEApplication(_data=str(signature), _subtype=MIMEWrapper._signature_subtype, - _encoder=encode_7or8bit) + _encoder=encode_7or8bit, + name='signature.asc') + second_part.add_header('content-description', + 'OpenPGP digital signature') + second_part.add_header('content-disposition', 'attachment', + filename='signature.asc') + out.attach(copy.deepcopy(self.msg)) out.attach(second_part) copy_headers(self.msg, out) diff --git a/src/mailman_pgp/pgp/utils.py b/src/mailman_pgp/pgp/utils.py index 1701c63..cc0bda0 100644 --- a/src/mailman_pgp/pgp/utils.py +++ b/src/mailman_pgp/pgp/utils.py @@ -20,3 +20,5 @@ def copy_headers(from_msg, to_msg): for key, value in from_msg.items(): if key not in to_msg: to_msg[key] = value + if to_msg.get_unixfrom() is None: + to_msg.set_unixfrom(from_msg.get_unixfrom()) |
