summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormh <mh@immerda.ch>2011-09-29 22:02:44 +0200
committermh <mh@immerda.ch>2011-09-29 22:02:44 +0200
commit82ba447ad5d159594433cbc4091f3f5291262d8d (patch)
treecc9471d88265f5e0eeef1b5f14067e5aeeefe979
parentbc4c57d305dbfb61fa0717bad37c49d393891146 (diff)
some small fixesHEADmaster
-rw-r--r--lib/mail_gnupg/interceptor/pgp_variants.rb2
-rw-r--r--lib/mail_gnupg/interceptor/pgp_variants/mime.rb26
-rw-r--r--lib/mail_gnupg/interceptor/pgp_variants/plain.rb4
3 files changed, 22 insertions, 10 deletions
diff --git a/lib/mail_gnupg/interceptor/pgp_variants.rb b/lib/mail_gnupg/interceptor/pgp_variants.rb
index 43a7aab..b00581c 100644
--- a/lib/mail_gnupg/interceptor/pgp_variants.rb
+++ b/lib/mail_gnupg/interceptor/pgp_variants.rb
@@ -4,7 +4,7 @@ module MailGnupg
private
def handle_mail(mail,variant='mime',encrypt=true,sign=true)
if encrypt
- send("encrypt_sign_mail_#{variant.downcase}",mail,sign)
+ send("encrypt_mail_#{variant.downcase}",mail,sign)
else
send("sign_mail_#{variant.downcase}",mail)
end
diff --git a/lib/mail_gnupg/interceptor/pgp_variants/mime.rb b/lib/mail_gnupg/interceptor/pgp_variants/mime.rb
index 6d37b26..ca1cd69 100644
--- a/lib/mail_gnupg/interceptor/pgp_variants/mime.rb
+++ b/lib/mail_gnupg/interceptor/pgp_variants/mime.rb
@@ -3,7 +3,7 @@ module MailGnupg
module PgpVariants
module Mime
private
-
+
def encrypt_mail_mime(mail,sign)
gpgcontent = Mail.new do |gpgmail|
if mail.multipart?
@@ -11,27 +11,34 @@ module MailGnupg
else
gpgmail.body = mail.body.raw_source
gpgmail.content_type = mail.content_type
+
+ # somehow mail warns otherwise about it
+ gpgmail.charset = mail.charset
end
end
-
+
+ # somehow mail warns otherwise about it
+ mail.charset = mail.charset
+
encrypted_body = encrypt_sign(gpgcontent.to_s,sign)
-
+
mail.content_type 'multipart/encrypted; protocol="application/pgp-encrypted"'
mail.mime_version = '1.0'
-
+
mail.body = ''
mail.parts.clear
-
+
mail.part :content_type => 'application/pgp-encrypted', :content_disposition => 'attachement', :body => "Version: 1\n"
mail.attachments['message.asc'] = {
:content_type => 'application/octet-stream',
:content_disposition => 'inline; filename="message.asc"',
:content => encrypted_body
}
+
mail
end
end
-
+
def sign_mail_mime(mail)
gpgcontent = Mail::Part.new do |gpgpart|
if mail.multipart?
@@ -59,7 +66,7 @@ module MailGnupg
# RFC 3156 requires it to be set in the content-type. ruby-gpgme
# doesn't provide it to us, though.
mail.content_type 'multipart/signed; protocol="application/pgp-signature"; micalg=pgp-sha1'
-
+
mail.add_part(Mail::Part.new('Content-Type: application/pgp-signature;') do |p|
p.body = 'dummy part to sign - will be removed later'
end)
@@ -78,6 +85,11 @@ module MailGnupg
tobesigned_crlf = parts[2].gsub(/\n/, "\r\n").gsub(/\r\r/, "\r")
mail.parts.last.body = sign(tobesigned_crlf)
+
+ # somehow mail warns otherwise about it
+ mail.charset = mail.charset
+
+ mail
end
end
end
diff --git a/lib/mail_gnupg/interceptor/pgp_variants/plain.rb b/lib/mail_gnupg/interceptor/pgp_variants/plain.rb
index 9d24506..5376ec3 100644
--- a/lib/mail_gnupg/interceptor/pgp_variants/plain.rb
+++ b/lib/mail_gnupg/interceptor/pgp_variants/plain.rb
@@ -3,7 +3,7 @@ module MailGnupg
module PgpVariants
module Plain
private
- def encrypt_sign_mail_plain(mail,sign=true)
+ def encrypt_mail_plain(mail,sign=true)
if mail.multipart?
mail.parts.each_with_index do |p,i|
mail.parts[i] = encrypt_sign_pgp_inline(p,sign)
@@ -33,7 +33,7 @@ module MailGnupg
else
mail.body = clearsign(mail.body.to_s)
end
- # somehowe mail warns otherwise about it
+ # somehow mail warns otherwise about it
mail.charset = mail.charset
end