mail 2.5.4 → 2.5.5.rc1

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of mail might be problematic. Click here for more details.

@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 80272f9450b9b4e8fda722e90b035af0571714a7
4
+ data.tar.gz: 4ccdee5a66dcb916988af7e26fa5aa40ca0486ca
5
+ SHA512:
6
+ metadata.gz: 306abdee9ff345ecdf15fc1bbcf3b894d3becfc3aaf4c254931ad088dda67a5043762d263de6dec3f432146d44d1a595aa23d534cb345736dc435738bff3e682
7
+ data.tar.gz: bb33d18fdbdc381e4c6b0d7aef3c2495dc4d1205bea210f5118bb18c0e6d4bfe5a87df5330a103fa0b8d4fdac62511b264b21f22d50c59599585c0a631731243
@@ -1,5 +1,10 @@
1
- == HEAD
1
+ == Version 2.5.5 - unreleased
2
2
 
3
+ Security:
4
+ * #1097 – SMTP security: prevent command injection via To/From addresses. (jeremy)
5
+
6
+ Bugs:
7
+ * #633 – Cope with message parts that have an empty Content-Type (ThomasKoppensteiner, zeepeeare)
3
8
 
4
9
  == Version 2.5.4 - Tue May 14 14:45:00 +1100 2013 Mikel Lindsaar <mikel@lindsaar.net>
5
10
 
data/Gemfile CHANGED
@@ -2,12 +2,14 @@ source 'https://rubygems.org'
2
2
 
3
3
  gemspec
4
4
 
5
+ gem "rake", "< 11.0" if RUBY_VERSION < '1.9.3'
6
+
5
7
  gem "treetop", "~> 1.4.10"
6
8
  gem "mime-types", "~> 1.16"
7
9
  gem "tlsmail" if RUBY_VERSION <= '1.8.6'
8
10
 
9
11
  gem 'jruby-openssl', :platform => :jruby
10
12
 
11
- group :test do
12
- gem "ruby-debug", :platform => :mri_18
13
+ # For gems not required to run tests
14
+ group :local_development, :test do
13
15
  end
data/README.md CHANGED
@@ -15,11 +15,11 @@ Built from my experience with TMail, it is designed to be a pure ruby
15
15
  implementation that makes generating, sending and parsing emails a no
16
16
  brainer.
17
17
 
18
- It is also designed form the ground up to work with Ruby 1.9. This is because
19
- Ruby 1.9 handles text encodings much more magically than Ruby 1.8.x and so
20
- these features have been taken full advantage of in this library allowing
21
- Mail to handle a lot more messages more cleanly than TMail. Mail does run on
22
- Ruby 1.8.x... it's just not as fun to code.
18
+ It is also designed form the ground up to work with the more modern versions
19
+ of Ruby. This is because Ruby > 1.9 handles text encodings much more wonderfully
20
+ than Ruby 1.8.x and so these features have been taken full advantage of in this
21
+ library allowing Mail to handle a lot more messages more cleanly than TMail.
22
+ Mail does run on Ruby 1.8.x... it's just not as fun to code.
23
23
 
24
24
  Finally, Mail has been designed with a very simple object oriented system
25
25
  that really opens up the email messages you are parsing, if you know what
@@ -44,14 +44,15 @@ Compatibility
44
44
 
45
45
  Every Mail commit is tested by Travis on the [following platforms](https://github.com/mikel/mail/blob/master/.travis.yml)
46
46
 
47
- * ruby-1.8.7-p370 [ i686 ]
48
- * ruby-1.9.2-p290 [ x86_64 ]
49
- * ruby-1.9.3-p327 [ x86_64 ]
50
- * ruby-2.0.0-rc1 [ x86_64 ]
51
- * jruby-1.6.8 [ x86_64 ]
52
- * jruby-1.7.0 [ x86_64 ]
53
- * rbx-d18 [ x86_64 ]
54
- * rbx-d19 [ x86_64 ]
47
+ * ruby-1.8.7 [ i686 ]
48
+ * ruby-1.9.2 [ x86_64 ]
49
+ * ruby-1.9.3 [ x86_64 ]
50
+ * ruby-2.0.0 [ x86_64 ]
51
+ * ruby-2.1.2 [ x86_64 ]
52
+ * ruby-head [ x86_64 ]
53
+ * jruby [ x86_64 ]
54
+ * jruby-head [ x86_64 ]
55
+ * rbx-2 [ x86_64 ]
55
56
 
56
57
  Discussion
57
58
  ----------
@@ -1,4 +1,4 @@
1
1
  major:2
2
2
  minor:5
3
- patch:4
4
- build:
3
+ patch:5
4
+ build:rc1
@@ -1,20 +1,57 @@
1
1
  module Mail
2
- module CheckDeliveryParams
3
- def check_delivery_params(mail)
4
- if mail.smtp_envelope_from.blank?
5
- raise ArgumentError.new('An SMTP From address is required to send a message. Set the message smtp_envelope_from, return_path, sender, or from address.')
2
+ module CheckDeliveryParams #:nodoc:
3
+ class << self
4
+ def check(mail)
5
+ [ check_from(mail.smtp_envelope_from),
6
+ check_to(mail.smtp_envelope_to),
7
+ check_message(mail) ]
6
8
  end
7
9
 
8
- if mail.smtp_envelope_to.blank?
9
- raise ArgumentError.new('An SMTP To address is required to send a message. Set the message smtp_envelope_to, to, cc, or bcc address.')
10
+ def check_from(addr)
11
+ if addr.blank?
12
+ raise ArgumentError, "SMTP From address may not be blank: #{addr.inspect}"
13
+ end
14
+
15
+ check_addr 'From', addr
16
+ end
17
+
18
+ def check_to(addrs)
19
+ if addrs.blank?
20
+ raise ArgumentError, "SMTP To address may not be blank: #{addrs.inspect}"
21
+ end
22
+
23
+ Array(addrs).map do |addr|
24
+ check_addr 'To', addr
25
+ end
10
26
  end
11
27
 
12
- message = mail.encoded if mail.respond_to?(:encoded)
13
- if message.blank?
14
- raise ArgumentError.new('An encoded message is required to send an email')
28
+ def check_addr(addr_name, addr)
29
+ validate_smtp_addr addr do |error_message|
30
+ raise ArgumentError, "SMTP #{addr_name} address #{error_message}: #{addr.inspect}"
31
+ end
15
32
  end
16
33
 
17
- [mail.smtp_envelope_from, mail.smtp_envelope_to, message]
34
+ def validate_smtp_addr(addr)
35
+ if addr.bytesize > 2048
36
+ yield 'may not exceed 2kB'
37
+ end
38
+
39
+ if /[\r\n]/ =~ addr
40
+ yield 'may not contain CR or LF line breaks'
41
+ end
42
+
43
+ addr
44
+ end
45
+
46
+ def check_message(message)
47
+ message = message.encoded if message.respond_to?(:encoded)
48
+
49
+ if message.blank?
50
+ raise ArgumentError, 'An encoded message is required to send an email'
51
+ end
52
+
53
+ message
54
+ end
18
55
  end
19
56
  end
20
57
  end
@@ -1,7 +1,6 @@
1
1
  require 'mail/check_delivery_params'
2
2
 
3
3
  module Mail
4
-
5
4
  # FileDelivery class delivers emails into multiple files based on the destination
6
5
  # address. Each file is appended to if it already exists.
7
6
  #
@@ -13,22 +12,20 @@ module Mail
13
12
  # Make sure the path you specify with :location is writable by the Ruby process
14
13
  # running Mail.
15
14
  class FileDelivery
16
- include Mail::CheckDeliveryParams
17
-
18
15
  if RUBY_VERSION >= '1.9.1'
19
16
  require 'fileutils'
20
17
  else
21
18
  require 'ftools'
22
19
  end
23
20
 
21
+ attr_accessor :settings
22
+
24
23
  def initialize(values)
25
24
  self.settings = { :location => './mails' }.merge!(values)
26
25
  end
27
-
28
- attr_accessor :settings
29
-
26
+
30
27
  def deliver!(mail)
31
- check_delivery_params(mail)
28
+ Mail::CheckDeliveryParams.check(mail)
32
29
 
33
30
  if ::File.respond_to?(:makedirs)
34
31
  ::File.makedirs settings[:location]
@@ -40,6 +37,5 @@ module Mail
40
37
  ::File.open(::File.join(settings[:location], File.basename(to.to_s)), 'a') { |f| "#{f.write(mail.encoded)}\r\n\r\n" }
41
38
  end
42
39
  end
43
-
44
40
  end
45
41
  end
@@ -37,17 +37,15 @@ module Mail
37
37
  #
38
38
  # mail.deliver!
39
39
  class Sendmail
40
- include Mail::CheckDeliveryParams
40
+ attr_accessor :settings
41
41
 
42
42
  def initialize(values)
43
43
  self.settings = { :location => '/usr/sbin/sendmail',
44
44
  :arguments => '-i' }.merge(values)
45
45
  end
46
46
 
47
- attr_accessor :settings
48
-
49
47
  def deliver!(mail)
50
- smtp_from, smtp_to, message = check_delivery_params(mail)
48
+ smtp_from, smtp_to, message = Mail::CheckDeliveryParams.check(mail)
51
49
 
52
50
  from = "-f #{self.class.shellquote(smtp_from)}"
53
51
  to = smtp_to.map { |to| self.class.shellquote(to) }.join(' ')
@@ -74,7 +74,7 @@ module Mail
74
74
  #
75
75
  # mail.deliver!
76
76
  class SMTP
77
- include Mail::CheckDeliveryParams
77
+ attr_accessor :settings
78
78
 
79
79
  def initialize(values)
80
80
  self.settings = { :address => "localhost",
@@ -90,12 +90,10 @@ module Mail
90
90
  }.merge!(values)
91
91
  end
92
92
 
93
- attr_accessor :settings
94
-
95
93
  # Send the message via SMTP.
96
94
  # The from and to attributes are optional. If not set, they are retrieve from the Message.
97
95
  def deliver!(mail)
98
- smtp_from, smtp_to, message = check_delivery_params(mail)
96
+ smtp_from, smtp_to, message = Mail::CheckDeliveryParams.check(mail)
99
97
 
100
98
  smtp = Net::SMTP.new(settings[:address], settings[:port])
101
99
  if settings[:tls] || settings[:ssl]
@@ -119,7 +117,6 @@ module Mail
119
117
  self
120
118
  end
121
119
  end
122
-
123
120
 
124
121
  private
125
122
 
@@ -37,7 +37,7 @@ module Mail
37
37
  #
38
38
  # mail.deliver!
39
39
  class SMTPConnection
40
- include Mail::CheckDeliveryParams
40
+ attr_accessor :smtp, :settings
41
41
 
42
42
  def initialize(values)
43
43
  raise ArgumentError.new('A Net::SMTP object is required for this delivery method') if values[:connection].nil?
@@ -45,17 +45,13 @@ module Mail
45
45
  self.settings = values
46
46
  end
47
47
 
48
- attr_accessor :smtp
49
- attr_accessor :settings
50
-
51
48
  # Send the message via SMTP.
52
49
  # The from and to attributes are optional. If not set, they are retrieve from the Message.
53
50
  def deliver!(mail)
54
- smtp_from, smtp_to, message = check_delivery_params(mail)
51
+ smtp_from, smtp_to, message = Mail::CheckDeliveryParams.check(mail)
55
52
  response = smtp.sendmail(message, smtp_from, smtp_to)
56
53
 
57
54
  settings[:return_response] ? response : self
58
55
  end
59
-
60
56
  end
61
57
  end
@@ -7,10 +7,8 @@ module Mail
7
7
  # It also provides a template of the minimum methods you require to implement
8
8
  # if you want to make a custom mailer for Mail
9
9
  class TestMailer
10
- include Mail::CheckDeliveryParams
11
-
12
10
  # Provides a store of all the emails sent with the TestMailer so you can check them.
13
- def TestMailer.deliveries
11
+ def self.deliveries
14
12
  @@deliveries ||= []
15
13
  end
16
14
 
@@ -25,20 +23,19 @@ module Mail
25
23
  # * length
26
24
  # * size
27
25
  # * and other common Array methods
28
- def TestMailer.deliveries=(val)
26
+ def self.deliveries=(val)
29
27
  @@deliveries = val
30
28
  end
31
29
 
30
+ attr_accessor :settings
31
+
32
32
  def initialize(values)
33
33
  @settings = values.dup
34
34
  end
35
-
36
- attr_accessor :settings
37
35
 
38
36
  def deliver!(mail)
39
- check_delivery_params(mail)
37
+ Mail::CheckDeliveryParams.check(mail)
40
38
  Mail::TestMailer.deliveries << mail
41
39
  end
42
-
43
40
  end
44
41
  end
@@ -44,7 +44,7 @@ module Mail
44
44
  private
45
45
 
46
46
  def get_order_value(part, order)
47
- if part.respond_to?(:content_type)
47
+ if part.respond_to?(:content_type) && !part[:content_type].nil?
48
48
  order.index(part[:content_type].string.downcase) || 10000
49
49
  else
50
50
  10000
@@ -73,6 +73,9 @@ module Mail
73
73
  string = string.sub(/\=$/, '')
74
74
  str = Encodings::QuotedPrintable.decode(string)
75
75
  str.force_encoding(pick_encoding(charset))
76
+ # We assume that binary strings hold utf-8 directly to work around
77
+ # jruby/jruby#829 which subtly changes String#encode semantics.
78
+ str.force_encoding('utf-8') if str.encoding == Encoding::ASCII_8BIT
76
79
  end
77
80
  decoded = str.encode("utf-8", :invalid => :replace, :replace => "")
78
81
  decoded.valid_encoding? ? decoded : decoded.encode("utf-16le", :invalid => :replace, :replace => "").encode("utf-8")
metadata CHANGED
@@ -1,110 +1,97 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mail
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.5.4
5
- prerelease:
4
+ version: 2.5.5.rc1
6
5
  platform: ruby
7
6
  authors:
8
7
  - Mikel Lindsaar
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-05-14 00:00:00.000000000 Z
11
+ date: 2017-05-09 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: mime-types
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ~>
17
+ - - "~>"
20
18
  - !ruby/object:Gem::Version
21
19
  version: '1.16'
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ~>
24
+ - - "~>"
28
25
  - !ruby/object:Gem::Version
29
26
  version: '1.16'
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: treetop
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
- - - ~>
31
+ - - "~>"
36
32
  - !ruby/object:Gem::Version
37
33
  version: 1.4.8
38
34
  type: :runtime
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
- - - ~>
38
+ - - "~>"
44
39
  - !ruby/object:Gem::Version
45
40
  version: 1.4.8
46
41
  - !ruby/object:Gem::Dependency
47
42
  name: bundler
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
- - - ! '>='
45
+ - - ">="
52
46
  - !ruby/object:Gem::Version
53
47
  version: 1.0.3
54
48
  type: :development
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
51
  requirements:
59
- - - ! '>='
52
+ - - ">="
60
53
  - !ruby/object:Gem::Version
61
54
  version: 1.0.3
62
55
  - !ruby/object:Gem::Dependency
63
56
  name: rake
64
57
  requirement: !ruby/object:Gem::Requirement
65
- none: false
66
58
  requirements:
67
- - - ! '>'
59
+ - - ">"
68
60
  - !ruby/object:Gem::Version
69
61
  version: 0.8.7
70
62
  type: :development
71
63
  prerelease: false
72
64
  version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
65
  requirements:
75
- - - ! '>'
66
+ - - ">"
76
67
  - !ruby/object:Gem::Version
77
68
  version: 0.8.7
78
69
  - !ruby/object:Gem::Dependency
79
70
  name: rspec
80
71
  requirement: !ruby/object:Gem::Requirement
81
- none: false
82
72
  requirements:
83
- - - ~>
73
+ - - "~>"
84
74
  - !ruby/object:Gem::Version
85
75
  version: 2.12.0
86
76
  type: :development
87
77
  prerelease: false
88
78
  version_requirements: !ruby/object:Gem::Requirement
89
- none: false
90
79
  requirements:
91
- - - ~>
80
+ - - "~>"
92
81
  - !ruby/object:Gem::Version
93
82
  version: 2.12.0
94
83
  - !ruby/object:Gem::Dependency
95
84
  name: rdoc
96
85
  requirement: !ruby/object:Gem::Requirement
97
- none: false
98
86
  requirements:
99
- - - ! '>='
87
+ - - ">="
100
88
  - !ruby/object:Gem::Version
101
89
  version: '0'
102
90
  type: :development
103
91
  prerelease: false
104
92
  version_requirements: !ruby/object:Gem::Requirement
105
- none: false
106
93
  requirements:
107
- - - ! '>='
94
+ - - ">="
108
95
  - !ruby/object:Gem::Version
109
96
  version: '0'
110
97
  description: A really Ruby Mail handler.
@@ -117,15 +104,17 @@ extra_rdoc_files:
117
104
  - CHANGELOG.rdoc
118
105
  - TODO.rdoc
119
106
  files:
120
- - README.md
121
- - MIT-LICENSE
122
- - CONTRIBUTING.md
123
107
  - CHANGELOG.rdoc
108
+ - CONTRIBUTING.md
124
109
  - Dependencies.txt
125
110
  - Gemfile
111
+ - MIT-LICENSE
112
+ - README.md
126
113
  - Rakefile
127
114
  - TODO.rdoc
115
+ - lib/VERSION
128
116
  - lib/load_parsers.rb
117
+ - lib/mail.rb
129
118
  - lib/mail/attachments_list.rb
130
119
  - lib/mail/body.rb
131
120
  - lib/mail/check_delivery_params.rb
@@ -133,9 +122,10 @@ files:
133
122
  - lib/mail/core_extensions/nil.rb
134
123
  - lib/mail/core_extensions/object.rb
135
124
  - lib/mail/core_extensions/smtp.rb
125
+ - lib/mail/core_extensions/string.rb
136
126
  - lib/mail/core_extensions/string/access.rb
137
127
  - lib/mail/core_extensions/string/multibyte.rb
138
- - lib/mail/core_extensions/string.rb
128
+ - lib/mail/elements.rb
139
129
  - lib/mail/elements/address.rb
140
130
  - lib/mail/elements/address_list.rb
141
131
  - lib/mail/elements/content_disposition_element.rb
@@ -148,17 +138,17 @@ files:
148
138
  - lib/mail/elements/mime_version_element.rb
149
139
  - lib/mail/elements/phrase_list.rb
150
140
  - lib/mail/elements/received_element.rb
151
- - lib/mail/elements.rb
141
+ - lib/mail/encodings.rb
152
142
  - lib/mail/encodings/7bit.rb
153
143
  - lib/mail/encodings/8bit.rb
154
144
  - lib/mail/encodings/base64.rb
155
145
  - lib/mail/encodings/binary.rb
156
146
  - lib/mail/encodings/quoted_printable.rb
157
147
  - lib/mail/encodings/transfer_encoding.rb
158
- - lib/mail/encodings.rb
159
148
  - lib/mail/envelope.rb
160
149
  - lib/mail/field.rb
161
150
  - lib/mail/field_list.rb
151
+ - lib/mail/fields.rb
162
152
  - lib/mail/fields/bcc_field.rb
163
153
  - lib/mail/fields/cc_field.rb
164
154
  - lib/mail/fields/comments_field.rb
@@ -197,17 +187,17 @@ files:
197
187
  - lib/mail/fields/subject_field.rb
198
188
  - lib/mail/fields/to_field.rb
199
189
  - lib/mail/fields/unstructured_field.rb
200
- - lib/mail/fields.rb
201
190
  - lib/mail/header.rb
202
191
  - lib/mail/indifferent_hash.rb
203
192
  - lib/mail/mail.rb
204
193
  - lib/mail/matchers/has_sent_mail.rb
205
194
  - lib/mail/message.rb
195
+ - lib/mail/multibyte.rb
206
196
  - lib/mail/multibyte/chars.rb
207
197
  - lib/mail/multibyte/exceptions.rb
208
198
  - lib/mail/multibyte/unicode.rb
209
199
  - lib/mail/multibyte/utils.rb
210
- - lib/mail/multibyte.rb
200
+ - lib/mail/network.rb
211
201
  - lib/mail/network/delivery_methods/exim.rb
212
202
  - lib/mail/network/delivery_methods/file_delivery.rb
213
203
  - lib/mail/network/delivery_methods/sendmail.rb
@@ -218,7 +208,6 @@ files:
218
208
  - lib/mail/network/retriever_methods/imap.rb
219
209
  - lib/mail/network/retriever_methods/pop3.rb
220
210
  - lib/mail/network/retriever_methods/test_retriever.rb
221
- - lib/mail/network.rb
222
211
  - lib/mail/parsers/address_lists.rb
223
212
  - lib/mail/parsers/address_lists.treetop
224
213
  - lib/mail/parsers/content_disposition.rb
@@ -255,33 +244,30 @@ files:
255
244
  - lib/mail/version.rb
256
245
  - lib/mail/version_specific/ruby_1_8.rb
257
246
  - lib/mail/version_specific/ruby_1_9.rb
258
- - lib/mail.rb
259
247
  - lib/tasks/corpus.rake
260
248
  - lib/tasks/treetop.rake
261
- - lib/VERSION
262
249
  homepage: http://github.com/mikel/mail
263
250
  licenses:
264
251
  - MIT
252
+ metadata: {}
265
253
  post_install_message:
266
254
  rdoc_options: []
267
255
  require_paths:
268
256
  - lib
269
257
  required_ruby_version: !ruby/object:Gem::Requirement
270
- none: false
271
258
  requirements:
272
- - - ! '>='
259
+ - - ">="
273
260
  - !ruby/object:Gem::Version
274
261
  version: '0'
275
262
  required_rubygems_version: !ruby/object:Gem::Requirement
276
- none: false
277
263
  requirements:
278
- - - ! '>='
264
+ - - ">"
279
265
  - !ruby/object:Gem::Version
280
- version: '0'
266
+ version: 1.3.1
281
267
  requirements: []
282
268
  rubyforge_project:
283
- rubygems_version: 1.8.24
269
+ rubygems_version: 2.6.12
284
270
  signing_key:
285
- specification_version: 3
271
+ specification_version: 4
286
272
  summary: Mail provides a nice Ruby DSL for making, sending and reading emails.
287
273
  test_files: []