diff options
| author | J08nY | 2017-06-23 20:53:49 +0200 |
|---|---|---|
| committer | J08nY | 2017-06-23 20:53:49 +0200 |
| commit | fc3791771047b44143868c6dc5f113e4f9157bf5 (patch) | |
| tree | 35428b6aec14743878faa9fb081889946e7d95df /src/mailman_pgp/pgp/inline.py | |
| parent | 35f73955ab03c65936aad59511d92d87f645e3ea (diff) | |
| download | mailman-pgp-fc3791771047b44143868c6dc5f113e4f9157bf5.tar.gz mailman-pgp-fc3791771047b44143868c6dc5f113e4f9157bf5.tar.zst mailman-pgp-fc3791771047b44143868c6dc5f113e4f9157bf5.zip | |
Diffstat (limited to 'src/mailman_pgp/pgp/inline.py')
| -rw-r--r-- | src/mailman_pgp/pgp/inline.py | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/src/mailman_pgp/pgp/inline.py b/src/mailman_pgp/pgp/inline.py index a8e8004..94091cc 100644 --- a/src/mailman_pgp/pgp/inline.py +++ b/src/mailman_pgp/pgp/inline.py @@ -41,6 +41,22 @@ class InlineWrapper: def _as_string(self): return str(self.msg.get_payload()) + def _has_signature(self): + try: + msg = PGPMessage.from_blob(self._as_string()) + return msg.is_signed + except: + pass + return False + + def _has_message(self): + try: + msg = PGPMessage.from_blob(self._as_string()) + return msg.is_encrypted + except: + pass + return False + def _has_armor(self, block_type): try: dearm = Armorable.ascii_unarmor(self._as_string()) @@ -57,8 +73,7 @@ class InlineWrapper: :return: If the message is inline signed. :rtype: bool """ - # XXX: This doesnt handle non-cleartext signatures (gpg -s -a) - return self._is_inline() and self._has_armor('SIGNATURE') + return self._is_inline() and self._has_signature() def is_encrypted(self): """ @@ -67,8 +82,7 @@ class InlineWrapper: :return: If the message is inline encrypted. :rtype: bool """ - # XXX: This mistakes non-cleartext signature as encrypted. - return self._is_inline() and self._has_armor('MESSAGE') + return self._is_inline() and self._has_message() def has_keys(self): """ |
