mail 2.4.1 → 2.4.3

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.

data/CHANGELOG.rdoc CHANGED
@@ -1,4 +1,12 @@
1
- == Thu Jan 19 13:49:34 UTC 2012 Mikel Lindsaar <mikel@reinteractive.net>
1
+ == HEAD
2
+
3
+ == Version 2.4.3 - Tue Mar 6 19:38:00 UTC 2012 Mikel Lindsaar <mikel@reinteractive.net>
4
+
5
+ * Fix security vulnerability allowing command line exploit when using exim or sendmail from the command line
6
+ * Change Mail#deliver! to also inform the interceptors
7
+ * Encodings.value_decode(str): Treat lines with mixed encoding correctly when the line ends with a plain text part.
8
+
9
+ == Version 2.4.1 - Thu Jan 19 13:49:34 UTC 2012 Mikel Lindsaar <mikel@reinteractive.net>
2
10
 
3
11
  * Fix non ascii character folding problems
4
12
  * Handle multipart mail in Mail::Message#to_yaml / #from_yaml
@@ -8,7 +16,7 @@
8
16
  * Updated treetop to latest version, specs now run approximately 25-30% faster!
9
17
  * Version bump to 2.4.1 and gem release
10
18
 
11
- == Sun Jan 15 18:15:56 UTC 2011 Mikel Lindsaar <mikel@reinteractive.net>
19
+ == Version 2.4.0 - Sun Jan 15 18:15:56 UTC 2011 Mikel Lindsaar <mikel@reinteractive.net>
12
20
 
13
21
  * Speed up reading of messages by about 12x
14
22
  * Added Message#without_attachments! that removes all message's attachments
@@ -34,7 +42,7 @@
34
42
  * Lots of warnings fixed
35
43
  * Version bump to 2.4.0 and gem release
36
44
 
37
- == Tue Apr 26 09:59:56 UTC 2011 Mikel Lindsaar <mikel@rubyx.com>
45
+ == Version 2.3.0 - Tue Apr 26 09:59:56 UTC 2011 Mikel Lindsaar <mikel@rubyx.com>
38
46
 
39
47
  * Remove ActiveSupport from the dependencies, load Active Support if present, or use internals if not
40
48
  * Created v2.2 branch for all 2.2 related commits
data/Gemfile.lock CHANGED
@@ -1,6 +1,7 @@
1
1
  GEM
2
2
  remote: http://rubygems.org/
3
3
  specs:
4
+ ZenTest (4.4.2)
4
5
  activesupport (3.0.6)
5
6
  columnize (0.3.6)
6
7
  diff-lcs (1.1.3)
@@ -9,21 +10,19 @@ GEM
9
10
  rbx-require-relative (> 0.0.4)
10
11
  mime-types (1.16)
11
12
  polyglot (0.3.3)
12
- rake (0.9.2.2)
13
+ rake (0.8.7)
13
14
  rbx-require-relative (0.0.5)
14
- rspec (2.8.0)
15
- rspec-core (~> 2.8.0)
16
- rspec-expectations (~> 2.8.0)
17
- rspec-mocks (~> 2.8.0)
18
- rspec-core (2.8.0)
19
- rspec-expectations (2.8.0)
15
+ rspec (1.3.2)
16
+ rspec-core (2.4.0)
17
+ rspec-expectations (2.4.0)
20
18
  diff-lcs (~> 1.1.2)
21
- rspec-mocks (2.8.0)
19
+ rspec-mocks (2.4.0)
22
20
  ruby-debug (0.10.4)
23
21
  columnize (>= 0.1)
24
22
  ruby-debug-base (~> 0.10.4.0)
25
23
  ruby-debug-base (0.10.4)
26
24
  linecache (>= 0.3)
25
+ ruby-debug-base (0.10.4-java)
27
26
  treetop (1.4.10)
28
27
  polyglot
29
28
  polyglot (>= 0.3.1)
@@ -33,10 +32,16 @@ PLATFORMS
33
32
  ruby
34
33
 
35
34
  DEPENDENCIES
35
+ ZenTest (~> 4.4.0)
36
36
  activesupport (>= 2.3.6)
37
+ bundler
38
+ diff-lcs
37
39
  i18n (>= 0.4.0)
38
40
  mime-types (~> 1.16)
39
- rake (> 0.8.7)
40
- rspec (~> 2.8.0)
41
+ rake (~> 0.8.7)
42
+ rspec (~> 1.3.0)
43
+ rspec-core (~> 2.4.0)
44
+ rspec-expectations (~> 2.4.0)
45
+ rspec-mocks (~> 2.4.0)
41
46
  ruby-debug
42
- treetop (~> 1.4.10)
47
+ treetop (~> 1.4.8)
data/README.md CHANGED
@@ -25,6 +25,20 @@ 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
26
26
  you are doing, you can fiddle with every last bit of your email directly.
27
27
 
28
+ Donations
29
+ -------------
30
+
31
+ Mail has been downloaded millions of times, by people around the world, in fact,
32
+ it represents more than 1% of *all* gems downloaded.
33
+
34
+ It is (like all open source software) a labour of love and something I am doing
35
+ with my own free time. If you would like to say thanks, please feel free to
36
+ [make a donation](http://www.pledgie.com/campaigns/8790) and feel free to send
37
+ me a nice email :)
38
+
39
+ <a href='http://www.pledgie.com/campaigns/8790'><img alt='Click here to lend your support to: mail and make a donation at www.pledgie.com !' src='http://www.pledgie.com/campaigns/8790.png?skin_name=chrome' border='0' /></a>
40
+
41
+
28
42
  Compatibility
29
43
  -------------
30
44
 
data/lib/VERSION CHANGED
@@ -1,4 +1,4 @@
1
1
  major:2
2
2
  minor:4
3
- patch:1
3
+ patch:3
4
4
  build:
data/lib/mail.rb CHANGED
@@ -29,7 +29,7 @@ module Mail # :doc:
29
29
  require 'mail/core_extensions/nil'
30
30
  require 'mail/core_extensions/object'
31
31
  require 'mail/core_extensions/string'
32
- require 'mail/core_extensions/shellwords' unless String.new.respond_to?(:shellescape)
32
+ require 'mail/core_extensions/shell_escape'
33
33
  require 'mail/core_extensions/smtp' if RUBY_VERSION < '1.9.3'
34
34
  require 'mail/indifferent_hash'
35
35
 
@@ -0,0 +1,56 @@
1
+ # encoding: utf-8
2
+
3
+ # The following is an adaptation of ruby 1.9.2's shellwords.rb file,
4
+ # it is modified to include '+' in the allowed list to allow for
5
+ # sendmail to accept email addresses as the sender with a + in them
6
+ #
7
+ module Mail
8
+ module ShellEscape
9
+ # Escapes a string so that it can be safely used in a Bourne shell
10
+ # command line.
11
+ #
12
+ # Note that a resulted string should be used unquoted and is not
13
+ # intended for use in double quotes nor in single quotes.
14
+ #
15
+ # open("| grep #{Shellwords.escape(pattern)} file") { |pipe|
16
+ # # ...
17
+ # }
18
+ #
19
+ # +String#shellescape+ is a shorthand for this function.
20
+ #
21
+ # open("| grep #{pattern.shellescape} file") { |pipe|
22
+ # # ...
23
+ # }
24
+ #
25
+ def escape_for_shell(str)
26
+ # An empty argument will be skipped, so return empty quotes.
27
+ return "''" if str.empty?
28
+
29
+ str = str.dup
30
+
31
+ # Process as a single byte sequence because not all shell
32
+ # implementations are multibyte aware.
33
+ str.gsub!(/([^A-Za-z0-9_\s\+\-.,:\/@\n])/n, "\\\\\\1")
34
+
35
+ # A LF cannot be escaped with a backslash because a backslash + LF
36
+ # combo is regarded as line continuation and simply ignored.
37
+ str.gsub!(/\n/, "'\n'")
38
+
39
+ return str
40
+ end
41
+
42
+ module_function :escape_for_shell
43
+ end
44
+ end
45
+
46
+ class String
47
+ # call-seq:
48
+ # str.shellescape => string
49
+ #
50
+ # Escapes +str+ so that it can be safely used in a Bourne shell
51
+ # command line. See +Shellwords::shellescape+ for details.
52
+ #
53
+ def escape_for_shell
54
+ Mail::ShellEscape.escape_for_shell(self)
55
+ end
56
+ end
@@ -130,7 +130,7 @@ module Mail
130
130
  text.scan(/( # Group around entire regex to include it in matches
131
131
  \=\?[^?]+\?([QB])\?[^?]+?\?\= # Quoted String with subgroup for encoding method
132
132
  | # or
133
- .+?(?=\=\?) # Plain String
133
+ .+?(?=\=\?|$) # Plain String
134
134
  )/xmi).map do |matches|
135
135
  string, method = *matches
136
136
  if method == 'b' || method == 'B'
data/lib/mail/message.rb CHANGED
@@ -237,10 +237,11 @@ module Mail
237
237
  # This method bypasses checking perform_deliveries and raise_delivery_errors,
238
238
  # so use with caution.
239
239
  #
240
- # It still however fires callbacks to the observers if they are defined.
240
+ # It still however fires off the intercepters and calls the observers callbacks if they are defined.
241
241
  #
242
242
  # Returns self
243
243
  def deliver!
244
+ inform_interceptors
244
245
  response = delivery_method.deliver!(self)
245
246
  inform_observers
246
247
  delivery_method.settings[:return_response] ? response : self
@@ -1,12 +1,45 @@
1
1
  module Mail
2
2
 
3
+ # A delivery method implementation which sends via exim.
4
+ #
5
+ # To use this, first find out where the exim binary is on your computer,
6
+ # if you are on a mac or unix box, it is usually in /usr/sbin/exim, this will
7
+ # be your exim location.
8
+ #
9
+ # Mail.defaults do
10
+ # delivery_method :exim
11
+ # end
12
+ #
13
+ # Or if your exim binary is not at '/usr/sbin/exim'
14
+ #
15
+ # Mail.defaults do
16
+ # delivery_method :exim, :location => '/absolute/path/to/your/exim'
17
+ # end
18
+ #
19
+ # Then just deliver the email as normal:
20
+ #
21
+ # Mail.deliver do
22
+ # to 'mikel@test.lindsaar.net'
23
+ # from 'ada@test.lindsaar.net'
24
+ # subject 'testing exim'
25
+ # body 'testing exim'
26
+ # end
27
+ #
28
+ # Or by calling deliver on a Mail message
29
+ #
30
+ # mail = Mail.new do
31
+ # to 'mikel@test.lindsaar.net'
32
+ # from 'ada@test.lindsaar.net'
33
+ # subject 'testing exim'
34
+ # body 'testing exim'
35
+ # end
36
+ #
37
+ # mail.deliver!
3
38
  class Exim < Sendmail
4
39
 
5
- def deliver!(mail)
6
- envelope_from = mail.return_path || mail.sender || mail.from_addrs.first
7
- return_path = "-f \"#{envelope_from.to_s.shellescape}\"" if envelope_from
8
- arguments = [settings[:arguments], return_path].compact.join(" ")
9
- self.class.call(settings[:location], arguments, mail)
40
+ def initialize(values)
41
+ self.settings = { :location => '/usr/sbin/exim',
42
+ :arguments => '-i -t' }.merge(values)
10
43
  end
11
44
 
12
45
  def self.call(path, arguments, mail)
@@ -45,14 +45,14 @@ module Mail
45
45
 
46
46
  def deliver!(mail)
47
47
  envelope_from = mail.return_path || mail.sender || mail.from_addrs.first
48
- return_path = "-f \"#{envelope_from.to_s.gsub('"', '\"')}\"" if envelope_from
48
+ return_path = "-f " + '"' + envelope_from.escape_for_shell + '"' if envelope_from
49
49
 
50
50
  arguments = [settings[:arguments], return_path].compact.join(" ")
51
51
 
52
- Sendmail.call(settings[:location], arguments, mail.destinations.collect(&:shellescape).join(" "), mail)
52
+ self.class.call(settings[:location], arguments, mail.destinations.collect(&:escape_for_shell).join(" "), mail)
53
53
  end
54
54
 
55
- def Sendmail.call(path, arguments, destinations, mail)
55
+ def self.call(path, arguments, destinations, mail)
56
56
  IO.popen("#{path} #{arguments} #{destinations}", "w+") do |io|
57
57
  io.puts mail.encoded.to_lf
58
58
  io.flush
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mail
3
3
  version: !ruby/object:Gem::Version
4
- hash: 29
5
- prerelease:
4
+ hash: 25
5
+ prerelease: false
6
6
  segments:
7
7
  - 2
8
8
  - 4
9
- - 1
10
- version: 2.4.1
9
+ - 3
10
+ version: 2.4.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - Mikel Lindsaar
@@ -15,7 +15,8 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2012-01-20 00:00:00 Z
18
+ date: 2012-03-06 00:00:00 +11:00
19
+ default_executable:
19
20
  dependencies:
20
21
  - !ruby/object:Gem::Dependency
21
22
  name: mime-types
@@ -89,7 +90,7 @@ files:
89
90
  - lib/mail/configuration.rb
90
91
  - lib/mail/core_extensions/nil.rb
91
92
  - lib/mail/core_extensions/object.rb
92
- - lib/mail/core_extensions/shellwords.rb
93
+ - lib/mail/core_extensions/shell_escape.rb
93
94
  - lib/mail/core_extensions/smtp.rb
94
95
  - lib/mail/core_extensions/string/access.rb
95
96
  - lib/mail/core_extensions/string/multibyte.rb
@@ -216,6 +217,7 @@ files:
216
217
  - lib/tasks/corpus.rake
217
218
  - lib/tasks/treetop.rake
218
219
  - lib/VERSION
220
+ has_rdoc: true
219
221
  homepage: http://github.com/mikel/mail
220
222
  licenses: []
221
223
 
@@ -245,7 +247,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
245
247
  requirements: []
246
248
 
247
249
  rubyforge_project:
248
- rubygems_version: 1.8.10
250
+ rubygems_version: 1.3.7
249
251
  signing_key:
250
252
  specification_version: 3
251
253
  summary: Mail provides a nice Ruby DSL for making, sending and reading emails.
@@ -1,57 +0,0 @@
1
- # encoding: utf-8
2
-
3
- # The following is imported from ruby 1.9.2 shellwords.rb
4
- #
5
- module Shellwords
6
- # Escapes a string so that it can be safely used in a Bourne shell
7
- # command line.
8
- #
9
- # Note that a resulted string should be used unquoted and is not
10
- # intended for use in double quotes nor in single quotes.
11
- #
12
- # open("| grep #{Shellwords.escape(pattern)} file") { |pipe|
13
- # # ...
14
- # }
15
- #
16
- # +String#shellescape+ is a shorthand for this function.
17
- #
18
- # open("| grep #{pattern.shellescape} file") { |pipe|
19
- # # ...
20
- # }
21
- #
22
- def shellescape(str)
23
- # An empty argument will be skipped, so return empty quotes.
24
- return "''" if str.empty?
25
-
26
- str = str.dup
27
-
28
- # Process as a single byte sequence because not all shell
29
- # implementations are multibyte aware.
30
- str.gsub!(/([^A-Za-z0-9_\-.,:\/@\n])/n, "\\\\\\1")
31
-
32
- # A LF cannot be escaped with a backslash because a backslash + LF
33
- # combo is regarded as line continuation and simply ignored.
34
- str.gsub!(/\n/, "'\n'")
35
-
36
- return str
37
- end
38
-
39
- module_function :shellescape
40
-
41
- class << self
42
- alias escape shellescape
43
- end
44
-
45
- end
46
-
47
- class String
48
- # call-seq:
49
- # str.shellescape => string
50
- #
51
- # Escapes +str+ so that it can be safely used in a Bourne shell
52
- # command line. See +Shellwords::shellescape+ for details.
53
- #
54
- def shellescape
55
- Shellwords.escape(self)
56
- end
57
- end