mail 2.3.0 → 2.3.2

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/Gemfile CHANGED
@@ -15,6 +15,9 @@ group :test do
15
15
  gem "rake", "~> 0.8.7"
16
16
  gem "bundler"
17
17
  gem "rspec", "~> 1.3.0"
18
+ gem "rspec-core", "~> 2.4.0"
19
+ gem "rspec-mocks", "~> 2.4.0"
20
+ gem "rspec-expectations", "~> 2.4.0"
18
21
  gem "diff-lcs"
19
22
  case
20
23
  when defined?(RUBY_ENGINE) && RUBY_ENGINE == 'rbx'
@@ -1,4 +1,4 @@
1
1
  major:2
2
2
  minor:3
3
- patch:0
3
+ patch:2
4
4
  build:
@@ -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
 
@@ -33,6 +33,8 @@ module Mail
33
33
  Mail::SMTP
34
34
  when :sendmail
35
35
  Mail::Sendmail
36
+ when :exim
37
+ Mail::Exim
36
38
  when :file
37
39
  Mail::FileDelivery
38
40
  when :smtp_connection
@@ -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
@@ -4,6 +4,7 @@ module Mail
4
4
  autoload :SMTP, 'mail/network/delivery_methods/smtp'
5
5
  autoload :FileDelivery, 'mail/network/delivery_methods/file_delivery'
6
6
  autoload :Sendmail, 'mail/network/delivery_methods/sendmail'
7
+ autoload :Exim, 'mail/network/delivery_methods/exim'
7
8
  autoload :SMTPConnection, 'mail/network/delivery_methods/smtp_connection'
8
9
  autoload :TestMailer, 'mail/network/delivery_methods/test_mailer'
9
10
 
@@ -0,0 +1,53 @@
1
+ module Mail
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!
38
+ class Exim < Sendmail
39
+
40
+ def initialize(values)
41
+ self.settings = { :location => '/usr/sbin/exim',
42
+ :arguments => '-i -t' }.merge(values)
43
+ end
44
+
45
+ def self.call(path, arguments, mail)
46
+ IO.popen("#{path} #{arguments}", "w+") do |io|
47
+ io.puts mail.encoded.to_lf
48
+ io.flush
49
+ end
50
+ end
51
+
52
+ end
53
+ end
@@ -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.shellescape}\"" 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: 3
5
- prerelease:
4
+ hash: 7
5
+ prerelease: false
6
6
  segments:
7
7
  - 2
8
8
  - 3
9
- - 0
10
- version: 2.3.0
9
+ - 2
10
+ version: 2.3.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Mikel Lindsaar
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-04-26 00:00:00 +10:00
18
+ date: 2012-03-06 00:00:00 +11:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -87,7 +87,7 @@ files:
87
87
  - lib/mail/configuration.rb
88
88
  - lib/mail/core_extensions/nil.rb
89
89
  - lib/mail/core_extensions/object.rb
90
- - lib/mail/core_extensions/shellwords.rb
90
+ - lib/mail/core_extensions/shell_escape.rb
91
91
  - lib/mail/core_extensions/smtp.rb
92
92
  - lib/mail/core_extensions/string/access.rb
93
93
  - lib/mail/core_extensions/string/multibyte.rb
@@ -163,6 +163,7 @@ files:
163
163
  - lib/mail/multibyte/unicode.rb
164
164
  - lib/mail/multibyte/utils.rb
165
165
  - lib/mail/multibyte.rb
166
+ - lib/mail/network/delivery_methods/exim.rb
166
167
  - lib/mail/network/delivery_methods/file_delivery.rb
167
168
  - lib/mail/network/delivery_methods/sendmail.rb
168
169
  - lib/mail/network/delivery_methods/smtp.rb
@@ -242,7 +243,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
242
243
  requirements: []
243
244
 
244
245
  rubyforge_project:
245
- rubygems_version: 1.6.2
246
+ rubygems_version: 1.3.7
246
247
  signing_key:
247
248
  specification_version: 3
248
249
  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