mail 2.2.14 → 2.2.15

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.

@@ -1,3 +1,8 @@
1
+ == Wed 26 Jan 2011 02:23:09 UTC Mikel Lindsaar <mikel@rubyx.com>
2
+
3
+ * Update addresses passed into sendmail to escape them (Andy Lindeman)
4
+ * Version bump to 2.2.15 and gem release
5
+
1
6
  == Mon 3 Jan 2011 12:48:59 UTC Mikel Lindsaar <mikel@rubyx.com>
2
7
 
3
8
  * Update field_spec to handle encodings, closes issues 44 and 120 (Luis Lopez)
@@ -1,4 +1,4 @@
1
- patch:14
1
+ patch:15
2
2
  major:2
3
3
  build:
4
4
  minor:2
@@ -2,6 +2,7 @@
2
2
  module Mail # :doc:
3
3
 
4
4
  require 'date'
5
+ require 'shellwords'
5
6
 
6
7
  require 'active_support'
7
8
  require 'active_support/core_ext/class/attribute_accessors'
@@ -33,6 +34,7 @@ module Mail # :doc:
33
34
 
34
35
  require 'mail/core_extensions/nil'
35
36
  require 'mail/core_extensions/string'
37
+ require 'mail/core_extensions/shellwords' unless String.new.respond_to?(:shellescape)
36
38
  require 'mail/core_extensions/smtp' if RUBY_VERSION < '1.9.3'
37
39
 
38
40
  require 'mail/patterns'
@@ -0,0 +1,55 @@
1
+ # The following is imported from ruby 1.9.2 shellwords.rb
2
+ #
3
+ module Shellwords
4
+ # Escapes a string so that it can be safely used in a Bourne shell
5
+ # command line.
6
+ #
7
+ # Note that a resulted string should be used unquoted and is not
8
+ # intended for use in double quotes nor in single quotes.
9
+ #
10
+ # open("| grep #{Shellwords.escape(pattern)} file") { |pipe|
11
+ # # ...
12
+ # }
13
+ #
14
+ # +String#shellescape+ is a shorthand for this function.
15
+ #
16
+ # open("| grep #{pattern.shellescape} file") { |pipe|
17
+ # # ...
18
+ # }
19
+ #
20
+ def shellescape(str)
21
+ # An empty argument will be skipped, so return empty quotes.
22
+ return "''" if str.empty?
23
+
24
+ str = str.dup
25
+
26
+ # Process as a single byte sequence because not all shell
27
+ # implementations are multibyte aware.
28
+ str.gsub!(/([^A-Za-z0-9_\-.,:\/@\n])/n, "\\\\\\1")
29
+
30
+ # A LF cannot be escaped with a backslash because a backslash + LF
31
+ # combo is regarded as line continuation and simply ignored.
32
+ str.gsub!(/\n/, "'\n'")
33
+
34
+ return str
35
+ end
36
+
37
+ module_function :shellescape
38
+
39
+ class << self
40
+ alias escape shellescape
41
+ end
42
+
43
+ end
44
+
45
+ class String
46
+ # call-seq:
47
+ # str.shellescape => string
48
+ #
49
+ # Escapes +str+ so that it can be safely used in a Bourne shell
50
+ # command line. See +Shellwords::shellescape+ for details.
51
+ #
52
+ def shellescape
53
+ Shellwords.escape(self)
54
+ end
55
+ end
@@ -128,7 +128,7 @@ module Mail
128
128
  private
129
129
 
130
130
  def method_missing(name, *args, &block)
131
- if name.to_s =~ /([\w_]+)=/
131
+ if name.to_s =~ /(\w+)=/
132
132
  self.parameters[$1] = args.first
133
133
  @value = "#{content_type}; #{stringify(parameters)}"
134
134
  else
@@ -10,11 +10,11 @@ module Mail
10
10
  #
11
11
  # Creating via a string:
12
12
  #
13
- # string = 'To: mikel@test.lindsaar.net\r\n'
14
- # string << 'From: bob@test.lindsaar.net\r\n\r\n'
15
- # string << 'Subject: This is an email\r\n'
16
- # string << '\r\n'
17
- # string << 'This is the body'
13
+ # string = "To: mikel@test.lindsaar.net\r\n"
14
+ # string << "From: bob@test.lindsaar.net\r\n"
15
+ # string << "Subject: This is an email\r\n"
16
+ # string << "\r\n"
17
+ # string << "This is the body"
18
18
  # Mail.new(string)
19
19
  #
20
20
  # Or creating via a block:
@@ -30,8 +30,8 @@ module Mail
30
30
  #
31
31
  # message = Mail.new({:to => 'mikel@test.lindsaar.net',
32
32
  # 'from' => 'bob@test.lindsaar.net',
33
- # :subject 'This is an email',
34
- # :body 'This is the body' })
33
+ # :subject => 'This is an email',
34
+ # :body => 'This is the body' })
35
35
  #
36
36
  # Note, the hash keys can be strings or symbols, the passed in object
37
37
  # does not need to be a hash, it just needs to respond to :each_pair
@@ -1,57 +1,57 @@
1
1
  module Mail
2
2
  # A delivery method implementation which sends via sendmail.
3
- #
3
+ #
4
4
  # To use this, first find out where the sendmail binary is on your computer,
5
5
  # if you are on a mac or unix box, it is usually in /usr/sbin/sendmail, this will
6
6
  # be your sendmail location.
7
- #
7
+ #
8
8
  # Mail.defaults do
9
9
  # delivery_method :sendmail
10
10
  # end
11
- #
11
+ #
12
12
  # Or if your sendmail binary is not at '/usr/sbin/sendmail'
13
- #
13
+ #
14
14
  # Mail.defaults do
15
15
  # delivery_method :sendmail, :location => '/absolute/path/to/your/sendmail'
16
16
  # end
17
- #
17
+ #
18
18
  # Then just deliver the email as normal:
19
- #
19
+ #
20
20
  # Mail.deliver do
21
21
  # to 'mikel@test.lindsaar.net'
22
22
  # from 'ada@test.lindsaar.net'
23
23
  # subject 'testing sendmail'
24
24
  # body 'testing sendmail'
25
25
  # end
26
- #
26
+ #
27
27
  # Or by calling deliver on a Mail message
28
- #
28
+ #
29
29
  # mail = Mail.new do
30
30
  # to 'mikel@test.lindsaar.net'
31
31
  # from 'ada@test.lindsaar.net'
32
32
  # subject 'testing sendmail'
33
33
  # body 'testing sendmail'
34
34
  # end
35
- #
35
+ #
36
36
  # mail.deliver!
37
37
  class Sendmail
38
-
38
+
39
39
  def initialize(values)
40
40
  self.settings = { :location => '/usr/sbin/sendmail',
41
41
  :arguments => '-i -t' }.merge(values)
42
42
  end
43
-
43
+
44
44
  attr_accessor :settings
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}\"" if envelope_from
48
+ return_path = "-f \"#{envelope_from.to_s.shellescape}\"" if envelope_from
49
49
 
50
50
  arguments = [settings[:arguments], return_path].compact.join(" ")
51
-
52
- Sendmail.call(settings[:location], arguments, mail.destinations.join(" "), mail)
51
+
52
+ Sendmail.call(settings[:location], arguments, mail.destinations.collect(&:shellescape).join(" "), mail)
53
53
  end
54
-
54
+
55
55
  def Sendmail.call(path, arguments, destinations, mail)
56
56
  IO.popen("#{path} #{arguments} #{destinations}", "w+") do |io|
57
57
  io.puts mail.encoded.to_lf
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 2
7
7
  - 2
8
- - 14
9
- version: 2.2.14
8
+ - 15
9
+ version: 2.2.15
10
10
  platform: ruby
11
11
  authors:
12
12
  - Mikel Lindsaar
@@ -14,13 +14,14 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2011-01-05 00:00:00 +11:00
17
+ date: 2011-01-26 00:00:00 +11:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: activesupport
22
22
  prerelease: false
23
23
  requirement: &id001 !ruby/object:Gem::Requirement
24
+ none: false
24
25
  requirements:
25
26
  - - ">="
26
27
  - !ruby/object:Gem::Version
@@ -35,6 +36,7 @@ dependencies:
35
36
  name: mime-types
36
37
  prerelease: false
37
38
  requirement: &id002 !ruby/object:Gem::Requirement
39
+ none: false
38
40
  requirements:
39
41
  - - ~>
40
42
  - !ruby/object:Gem::Version
@@ -48,6 +50,7 @@ dependencies:
48
50
  name: treetop
49
51
  prerelease: false
50
52
  requirement: &id003 !ruby/object:Gem::Requirement
53
+ none: false
51
54
  requirements:
52
55
  - - ~>
53
56
  - !ruby/object:Gem::Version
@@ -62,6 +65,7 @@ dependencies:
62
65
  name: i18n
63
66
  prerelease: false
64
67
  requirement: &id004 !ruby/object:Gem::Requirement
68
+ none: false
65
69
  requirements:
66
70
  - - ">="
67
71
  - !ruby/object:Gem::Version
@@ -90,6 +94,7 @@ files:
90
94
  - lib/mail/body.rb
91
95
  - lib/mail/configuration.rb
92
96
  - lib/mail/core_extensions/nil.rb
97
+ - lib/mail/core_extensions/shellwords.rb
93
98
  - lib/mail/core_extensions/smtp.rb
94
99
  - lib/mail/core_extensions/string.rb
95
100
  - lib/mail/elements/address.rb
@@ -216,6 +221,7 @@ rdoc_options: []
216
221
  require_paths:
217
222
  - lib
218
223
  required_ruby_version: !ruby/object:Gem::Requirement
224
+ none: false
219
225
  requirements:
220
226
  - - ">="
221
227
  - !ruby/object:Gem::Version
@@ -223,6 +229,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
223
229
  - 0
224
230
  version: "0"
225
231
  required_rubygems_version: !ruby/object:Gem::Requirement
232
+ none: false
226
233
  requirements:
227
234
  - - ">="
228
235
  - !ruby/object:Gem::Version
@@ -232,7 +239,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
232
239
  requirements: []
233
240
 
234
241
  rubyforge_project:
235
- rubygems_version: 1.3.6
242
+ rubygems_version: 1.3.7
236
243
  signing_key:
237
244
  specification_version: 3
238
245
  summary: Mail provides a nice Ruby DSL for making, sending and reading emails.