Class: Mail::Gpg::InlineSignedMessage
- Inherits:
-
Message
- Object
- Message
- Mail::Gpg::InlineSignedMessage
- Defined in:
- lib/mail/gpg/inline_signed_message.rb
Constant Summary collapse
- END_SIGNED_TEXT =
'-----END PGP SIGNED MESSAGE-----'
- END_SIGNED_TEXT_RE =
/^#{END_SIGNED_TEXT}\s*$/
- INLINE_SIG_RE =
Regexp.new('^-----BEGIN PGP SIGNATURE-----\s*$.*^-----END PGP SIGNATURE-----\s*$', Regexp::MULTILINE)
- BEGIN_SIG_RE =
/^(-----BEGIN PGP SIGNATURE-----)\s*$/
Class Method Summary collapse
-
.strip_inline_signature(signed_text) ⇒ Object
utility method to remove inline signature and related pgp markers.
Instance Method Summary collapse
-
#initialize(signed_mail, options = {}) ⇒ InlineSignedMessage
constructor
A new instance of InlineSignedMessage.
Constructor Details
#initialize(signed_mail, options = {}) ⇒ InlineSignedMessage
Returns a new instance of InlineSignedMessage.
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/mail/gpg/inline_signed_message.rb', line 7 def initialize(signed_mail, = {}) if signed_mail.multipart? super() do global_verify_result = [] signed_mail.header.fields.each do |field| header[field.name] = field.value end signed_mail.parts.each do |part| if Mail::Gpg.signed_inline?(part) signed_text = part.body.to_s success, vr = GpgmeHelper.inline_verify(signed_text, ) p = VerifiedPart.new(part) if success p.body self.class.strip_inline_signature signed_text end p.verify_result vr global_verify_result << vr add_part p else add_part part end end verify_result global_verify_result end # of multipart else super() do signed_mail.header.fields.each do |field| header[field.name] = field.value end signed_text = signed_mail.body.to_s success, vr = GpgmeHelper.inline_verify(signed_text, ) if success body self.class.strip_inline_signature signed_text else body signed_text end verify_result vr end end end |
Class Method Details
.strip_inline_signature(signed_text) ⇒ Object
utility method to remove inline signature and related pgp markers
55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/mail/gpg/inline_signed_message.rb', line 55 def self.strip_inline_signature(signed_text) if signed_text =~ INLINE_SIG_RE signed_text = signed_text.dup if signed_text !~ END_SIGNED_TEXT_RE # insert the 'end of signed text' marker in case it is missing signed_text = signed_text.gsub BEGIN_SIG_RE, "-----END PGP SIGNED MESSAGE-----\n\\1" end signed_text.gsub! INLINE_SIG_RE, '' signed_text.strip! end signed_text end |