mail-gpg 0.2.4 → 0.2.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.travis.yml +4 -3
- data/History.txt +4 -0
- data/lib/mail/gpg.rb +2 -2
- data/lib/mail/gpg/encrypted_part.rb +4 -2
- data/lib/mail/gpg/version.rb +1 -1
- data/test/gpg_test.rb +16 -0
- data/test/gpghome/pubring.gpg +0 -0
- data/test/gpghome/pubring.gpg~ +0 -0
- data/test/inline_decrypted_message_test.rb +2 -2
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0013a726cc36fd4eb141aa3f8f20887f27dbfbfb
|
4
|
+
data.tar.gz: 20eac895d6e3bc61712ebd63be00806421aa1618
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 05870d215e2ecfa634e6eb81fe6d21ef9642cdcaead05e3373970c3eda1b711346a3a908deea9635c66c448b367e20a65679d36fa86dea681ed5a45b63db6b9f
|
7
|
+
data.tar.gz: be35cf83e2cfbab24ec725a2dac1919196c3cd5cb238c5886d7d407f203edffac8d9f019e16e43c942f7672dd8e959863e506133323e062ca37452f989cd090f
|
data/.travis.yml
CHANGED
data/History.txt
CHANGED
data/lib/mail/gpg.rb
CHANGED
@@ -232,10 +232,10 @@ module Mail
|
|
232
232
|
# check if inline PGP (i.e. if any parts of the mail includes
|
233
233
|
# the PGP SIGNED marker)
|
234
234
|
def self.signed_inline?(mail)
|
235
|
-
return true if mail.body.
|
235
|
+
return true if mail.body.to_s =~ /^-----BEGIN PGP SIGNED MESSAGE-----/
|
236
236
|
if mail.multipart?
|
237
237
|
mail.parts.each do |part|
|
238
|
-
return true if part.body.
|
238
|
+
return true if part.body.to_s =~ /^-----BEGIN PGP SIGNED MESSAGE-----/
|
239
239
|
end
|
240
240
|
end
|
241
241
|
false
|
@@ -13,14 +13,16 @@ module Mail
|
|
13
13
|
# key ids. Imports any keys given here that are not already part of the
|
14
14
|
# local keychain before sending the mail.
|
15
15
|
# :always_trust : send encrypted mail to untrusted receivers, true by default
|
16
|
+
# :filename : define a custom name for the encrypted file attachment
|
16
17
|
def initialize(cleartext_mail, options = {})
|
17
18
|
options = { always_trust: true }.merge options
|
18
19
|
|
19
20
|
encrypted = GpgmeHelper.encrypt(cleartext_mail.encoded, options)
|
20
21
|
super() do
|
21
22
|
body encrypted.to_s
|
22
|
-
|
23
|
-
|
23
|
+
filename = options[:filename] || 'encrypted.asc'
|
24
|
+
content_type "#{CONTENT_TYPE}; name=\"#{filename}\""
|
25
|
+
content_disposition "inline; filename=\"#{filename}\""
|
24
26
|
content_description 'OpenPGP encrypted message'
|
25
27
|
end
|
26
28
|
end
|
data/lib/mail/gpg/version.rb
CHANGED
data/test/gpg_test.rb
CHANGED
@@ -20,6 +20,12 @@ class GpgTest < Test::Unit::TestCase
|
|
20
20
|
enc_part.content_type
|
21
21
|
end
|
22
22
|
|
23
|
+
def check_attachment_name(mail = @mail, encrypted = @encrypted)
|
24
|
+
v_part, enc_part = encrypted.parts
|
25
|
+
assert_equal 'application/octet-stream; name=custom_filename.asc', enc_part.content_type
|
26
|
+
assert_equal 'inline; filename=custom_filename.asc', enc_part.content_disposition
|
27
|
+
end
|
28
|
+
|
23
29
|
def check_content(mail = @mail, encrypted = @encrypted)
|
24
30
|
assert enc = encrypted.parts.last
|
25
31
|
assert clear = GPGME::Crypto.new.decrypt(enc.to_s, password: 'abc').to_s
|
@@ -235,6 +241,16 @@ class GpgTest < Test::Unit::TestCase
|
|
235
241
|
end
|
236
242
|
end
|
237
243
|
|
244
|
+
context 'simple mail (custom filename)' do
|
245
|
+
setup do
|
246
|
+
@encrypted = Mail::Gpg.encrypt(@mail, {filename: 'custom_filename.asc'})
|
247
|
+
end
|
248
|
+
|
249
|
+
should 'have same custom attachment filename' do
|
250
|
+
check_attachment_name
|
251
|
+
end
|
252
|
+
end
|
253
|
+
|
238
254
|
context 'simple mail (signed)' do
|
239
255
|
setup do
|
240
256
|
@encrypted = Mail::Gpg.encrypt(@mail, { :sign => true, :password => 'abc' })
|
data/test/gpghome/pubring.gpg
CHANGED
Binary file
|
data/test/gpghome/pubring.gpg~
CHANGED
Binary file
|
@@ -76,7 +76,7 @@ class InlineDecryptedMessageTest < Test::Unit::TestCase
|
|
76
76
|
assert !decrypted.encrypted?
|
77
77
|
check_headers(@mail, decrypted)
|
78
78
|
assert_equal 2, decrypted.parts.length
|
79
|
-
|
79
|
+
assert @mail.body.to_s == decrypted.parts[0].body.to_s
|
80
80
|
assert /application\/octet-stream; (?:charset=UTF-8; )?name=Rakefile/ =~ decrypted.parts[1].content_type
|
81
81
|
assert_equal 'attachment; filename=Rakefile', decrypted.parts[1].content_disposition
|
82
82
|
assert_equal rakefile, decrypted.parts[1].body.decoded
|
@@ -108,7 +108,7 @@ class InlineDecryptedMessageTest < Test::Unit::TestCase
|
|
108
108
|
assert !decrypted.encrypted?
|
109
109
|
check_headers(@mail, decrypted)
|
110
110
|
assert_equal 2, decrypted.parts.length
|
111
|
-
|
111
|
+
assert @mail.body.to_s == decrypted.parts[0].body.to_s
|
112
112
|
assert /application\/octet-stream; (?:charset=UTF-8; )?name=Rakefile/ =~ decrypted.parts[1].content_type
|
113
113
|
assert_equal 'attachment; filename=Rakefile', decrypted.parts[1].content_disposition
|
114
114
|
assert_equal rakefile, decrypted.parts[1].body.decoded
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mail-gpg
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jens Kraemer
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-09-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: mail
|
@@ -229,3 +229,4 @@ test_files:
|
|
229
229
|
- test/sign_part_test.rb
|
230
230
|
- test/test_helper.rb
|
231
231
|
- test/version_part_test.rb
|
232
|
+
has_rdoc:
|