mail-gpg 0.2.4 → 0.2.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 17026bb359e9e8681f5e61e5fbc2b53ede7daa68
4
- data.tar.gz: 084f875fc24201c8f074c27c8029e6b77ec6bb9e
3
+ metadata.gz: 0013a726cc36fd4eb141aa3f8f20887f27dbfbfb
4
+ data.tar.gz: 20eac895d6e3bc61712ebd63be00806421aa1618
5
5
  SHA512:
6
- metadata.gz: 893411f59ec0483c471d40ef7501948543f8405be9a3138c458d8728bbe8a8da480bf84a8cc298a99ce8f16038ef888162f6e65289c37003c29582d9f17f2830
7
- data.tar.gz: b859c9850ec90f8a9877b34db7d3a89918ad46c7f3331073caf01dec216e6cd62e82ce3e17105e584d611ef7c26315a38d62ec05bb5a6514cce911661d7cd068
6
+ metadata.gz: 05870d215e2ecfa634e6eb81fe6d21ef9642cdcaead05e3373970c3eda1b711346a3a908deea9635c66c448b367e20a65679d36fa86dea681ed5a45b63db6b9f
7
+ data.tar.gz: be35cf83e2cfbab24ec725a2dac1919196c3cd5cb238c5886d7d407f203edffac8d9f019e16e43c942f7672dd8e959863e506133323e062ca37452f989cd090f
data/.travis.yml CHANGED
@@ -1,9 +1,10 @@
1
1
  language: ruby
2
2
  rvm:
3
3
  - 2.2.2
4
- - 2.1.1
4
+ - 2.1.3
5
5
  - 2.0.0
6
6
  - 1.9.3
7
7
  env:
8
- - RAILS=3.2.14
9
- - RAILS=4.0.0
8
+ - RAILS=3.2.21
9
+ - RAILS=4.1.10
10
+ - RAILS=4.2.1
data/History.txt CHANGED
@@ -1,3 +1,7 @@
1
+ == 0.2.5 2015-09-30
2
+
3
+ * allow overriding of encrypted attachment name (patch by @chrislewis60)
4
+
1
5
  == 0.2.4 2015-04-20
2
6
 
3
7
  * preserve List-Id and List-Unsubscribe headers
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.include?('-----BEGIN PGP SIGNED MESSAGE-----')
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.include?('-----BEGIN PGP SIGNED MESSAGE-----')
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
- content_type "#{CONTENT_TYPE}; name=\"encrypted.asc\""
23
- content_disposition 'inline; filename="encrypted.asc"'
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
@@ -1,5 +1,5 @@
1
1
  module Mail
2
2
  module Gpg
3
- VERSION = "0.2.4"
3
+ VERSION = "0.2.5"
4
4
  end
5
5
  end
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' })
Binary file
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
- assert_equal @mail.body.to_s, decrypted.parts[0].body.to_s
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
- assert_equal @mail.body.to_s, decrypted.parts[0].body.to_s
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
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-04-20 00:00:00.000000000 Z
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: