mail 2.2.15 → 2.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGELOG.rdoc +38 -0
- data/Dependencies.txt +3 -0
- data/Gemfile +29 -0
- data/Rakefile +1 -1
- data/lib/VERSION +2 -2
- data/lib/mail/body.rb +10 -4
- data/lib/mail/configuration.rb +2 -0
- data/lib/mail/core_extensions/nil.rb +2 -0
- data/lib/mail/core_extensions/object.rb +13 -0
- data/lib/mail/core_extensions/shellwords.rb +2 -0
- data/lib/mail/core_extensions/smtp.rb +1 -0
- data/lib/mail/core_extensions/string/access.rb +104 -0
- data/lib/mail/core_extensions/string/multibyte.rb +78 -0
- data/lib/mail/core_extensions/string.rb +5 -1
- data/lib/mail/encodings.rb +43 -43
- data/lib/mail/field.rb +2 -1
- data/lib/mail/fields/common/common_message_id.rb +1 -1
- data/lib/mail/fields/common/parameter_hash.rb +5 -5
- data/lib/mail/fields/received_field.rb +11 -3
- data/lib/mail/fields/return_path_field.rb +1 -0
- data/lib/mail/fields/unstructured_field.rb +1 -0
- data/lib/mail/header.rb +2 -1
- data/lib/mail/indifferent_hash.rb +146 -0
- data/lib/mail/message.rb +26 -4
- data/lib/mail/multibyte/chars.rb +474 -0
- data/lib/mail/multibyte/exceptions.rb +8 -0
- data/lib/mail/multibyte/unicode.rb +392 -0
- data/lib/mail/multibyte/utils.rb +60 -0
- data/lib/mail/multibyte.rb +42 -0
- data/lib/mail/network/delivery_methods/smtp.rb +4 -3
- data/lib/mail/network/delivery_methods/smtp_connection.rb +74 -0
- data/lib/mail/network/retriever_methods/test_retriever.rb +8 -1
- data/lib/mail/network.rb +1 -0
- data/lib/mail/part.rb +1 -1
- data/lib/mail/parts_list.rb +17 -9
- data/lib/mail/version_specific/ruby_1_8.rb +14 -13
- data/lib/mail/version_specific/ruby_1_9.rb +19 -16
- data/lib/mail.rb +12 -7
- metadata +31 -28
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
# encoding: utf-8
|
|
2
|
+
|
|
2
3
|
module Mail
|
|
3
4
|
class Ruby18
|
|
4
5
|
require 'base64'
|
|
@@ -14,13 +15,13 @@ module Mail
|
|
|
14
15
|
re = /([\(\)])/ # Only match unescaped parens
|
|
15
16
|
str.gsub(re) { |s| '\\' + s }
|
|
16
17
|
end
|
|
17
|
-
|
|
18
|
+
|
|
18
19
|
def Ruby18.paren( str )
|
|
19
20
|
str = $1 if str =~ /^\((.*)?\)$/
|
|
20
21
|
str = escape_paren( str )
|
|
21
22
|
'(' + str + ')'
|
|
22
23
|
end
|
|
23
|
-
|
|
24
|
+
|
|
24
25
|
def Ruby18.escape_bracket( str )
|
|
25
26
|
re = /\\\>/
|
|
26
27
|
str = str.gsub(re) { |s| '>'}
|
|
@@ -29,36 +30,36 @@ module Mail
|
|
|
29
30
|
re = /([\<\>])/ # Only match unescaped parens
|
|
30
31
|
str.gsub(re) { |s| '\\' + s }
|
|
31
32
|
end
|
|
32
|
-
|
|
33
|
+
|
|
33
34
|
def Ruby18.bracket( str )
|
|
34
35
|
str = $1 if str =~ /^\<(.*)?\>$/
|
|
35
36
|
str = escape_bracket( str )
|
|
36
37
|
'<' + str + '>'
|
|
37
38
|
end
|
|
38
|
-
|
|
39
|
+
|
|
39
40
|
def Ruby18.decode_base64(str)
|
|
40
41
|
Base64.decode64(str) if str
|
|
41
42
|
end
|
|
42
|
-
|
|
43
|
+
|
|
43
44
|
def Ruby18.encode_base64(str)
|
|
44
45
|
Base64.encode64(str)
|
|
45
46
|
end
|
|
46
|
-
|
|
47
|
+
|
|
47
48
|
def Ruby18.has_constant?(klass, string)
|
|
48
49
|
klass.constants.include?( string )
|
|
49
50
|
end
|
|
50
|
-
|
|
51
|
+
|
|
51
52
|
def Ruby18.get_constant(klass, string)
|
|
52
53
|
klass.const_get( string )
|
|
53
54
|
end
|
|
54
|
-
|
|
55
|
+
|
|
55
56
|
def Ruby18.b_value_encode(str, encoding)
|
|
56
57
|
# Ruby 1.8 requires an encoding to work
|
|
57
58
|
raise ArgumentError, "Must supply an encoding" if encoding.nil?
|
|
58
59
|
encoding = encoding.to_s.upcase.gsub('_', '-')
|
|
59
60
|
[Encodings::Base64.encode(str), encoding]
|
|
60
61
|
end
|
|
61
|
-
|
|
62
|
+
|
|
62
63
|
def Ruby18.b_value_decode(str)
|
|
63
64
|
match = str.match(/\=\?(.+)?\?[Bb]\?(.+)?\?\=/m)
|
|
64
65
|
if match
|
|
@@ -67,14 +68,14 @@ module Mail
|
|
|
67
68
|
end
|
|
68
69
|
str
|
|
69
70
|
end
|
|
70
|
-
|
|
71
|
+
|
|
71
72
|
def Ruby18.q_value_encode(str, encoding)
|
|
72
73
|
# Ruby 1.8 requires an encoding to work
|
|
73
74
|
raise ArgumentError, "Must supply an encoding" if encoding.nil?
|
|
74
75
|
encoding = encoding.to_s.upcase.gsub('_', '-')
|
|
75
76
|
[Encodings::QuotedPrintable.encode(str), encoding]
|
|
76
77
|
end
|
|
77
|
-
|
|
78
|
+
|
|
78
79
|
def Ruby18.q_value_decode(str)
|
|
79
80
|
match = str.match(/\=\?(.+)?\?[Qq]\?(.+)?\?\=/m)
|
|
80
81
|
if match
|
|
@@ -83,11 +84,11 @@ module Mail
|
|
|
83
84
|
end
|
|
84
85
|
str
|
|
85
86
|
end
|
|
86
|
-
|
|
87
|
+
|
|
87
88
|
def Ruby18.param_decode(str, encoding)
|
|
88
89
|
URI.unescape(str)
|
|
89
90
|
end
|
|
90
|
-
|
|
91
|
+
|
|
91
92
|
def Ruby18.param_encode(str)
|
|
92
93
|
encoding = $KCODE.to_s.downcase
|
|
93
94
|
language = Configuration.instance.param_encode_language
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
# encoding: utf-8
|
|
2
|
+
|
|
2
3
|
module Mail
|
|
3
4
|
class Ruby19
|
|
4
5
|
|
|
@@ -14,7 +15,7 @@ module Mail
|
|
|
14
15
|
str = escape_paren( str )
|
|
15
16
|
'(' + str + ')'
|
|
16
17
|
end
|
|
17
|
-
|
|
18
|
+
|
|
18
19
|
def Ruby19.escape_bracket( str )
|
|
19
20
|
re = /(?<!\\)([\<\>])/ # Only match unescaped brackets
|
|
20
21
|
str.gsub(re) { |s| '\\' + s }
|
|
@@ -27,26 +28,26 @@ module Mail
|
|
|
27
28
|
end
|
|
28
29
|
|
|
29
30
|
def Ruby19.decode_base64(str)
|
|
30
|
-
str.unpack( 'm' ).first
|
|
31
|
+
str.unpack( 'm' ).first
|
|
31
32
|
end
|
|
32
|
-
|
|
33
|
+
|
|
33
34
|
def Ruby19.encode_base64(str)
|
|
34
35
|
[str].pack( 'm' )
|
|
35
36
|
end
|
|
36
|
-
|
|
37
|
+
|
|
37
38
|
def Ruby19.has_constant?(klass, string)
|
|
38
|
-
klass.
|
|
39
|
+
klass.const_defined?( string, false )
|
|
39
40
|
end
|
|
40
|
-
|
|
41
|
+
|
|
41
42
|
def Ruby19.get_constant(klass, string)
|
|
42
|
-
klass.const_get( string
|
|
43
|
+
klass.const_get( string )
|
|
43
44
|
end
|
|
44
|
-
|
|
45
|
+
|
|
45
46
|
def Ruby19.b_value_encode(str, encoding = nil)
|
|
46
47
|
encoding = str.encoding.to_s
|
|
47
48
|
[Ruby19.encode_base64(str), encoding]
|
|
48
49
|
end
|
|
49
|
-
|
|
50
|
+
|
|
50
51
|
def Ruby19.b_value_decode(str)
|
|
51
52
|
match = str.match(/\=\?(.+)?\?[Bb]\?(.+)?\?\=/m)
|
|
52
53
|
if match
|
|
@@ -54,9 +55,10 @@ module Mail
|
|
|
54
55
|
str = Ruby19.decode_base64(match[2])
|
|
55
56
|
str.force_encoding(fix_encoding(encoding))
|
|
56
57
|
end
|
|
57
|
-
str.encode("utf-8", :invalid => :replace, :replace => "")
|
|
58
|
+
decoded = str.encode("utf-8", :invalid => :replace, :replace => "")
|
|
59
|
+
decoded.valid_encoding? ? decoded : decoded.encode("utf-16le", :invalid => :replace, :replace => "").encode("utf-8")
|
|
58
60
|
end
|
|
59
|
-
|
|
61
|
+
|
|
60
62
|
def Ruby19.q_value_encode(str, encoding = nil)
|
|
61
63
|
encoding = str.encoding.to_s
|
|
62
64
|
[Encodings::QuotedPrintable.encode(str), encoding]
|
|
@@ -69,7 +71,8 @@ module Mail
|
|
|
69
71
|
str = Encodings::QuotedPrintable.decode(match[2])
|
|
70
72
|
str.force_encoding(fix_encoding(encoding))
|
|
71
73
|
end
|
|
72
|
-
str.encode("utf-8", :invalid => :replace, :replace => "")
|
|
74
|
+
decoded = str.encode("utf-8", :invalid => :replace, :replace => "")
|
|
75
|
+
decoded.valid_encoding? ? decoded : decoded.encode("utf-16le", :invalid => :replace, :replace => "").encode("utf-8")
|
|
73
76
|
end
|
|
74
77
|
|
|
75
78
|
def Ruby19.param_decode(str, encoding)
|
|
@@ -84,8 +87,8 @@ module Mail
|
|
|
84
87
|
"#{encoding}'#{language}'#{URI.escape(str)}"
|
|
85
88
|
end
|
|
86
89
|
|
|
87
|
-
# mails somtimes includes invalid encodings like iso885915 or utf8 so we transform them to iso885915 or utf8
|
|
88
|
-
# TODO: add this as a test somewhere
|
|
90
|
+
# mails somtimes includes invalid encodings like iso885915 or utf8 so we transform them to iso885915 or utf8
|
|
91
|
+
# TODO: add this as a test somewhere
|
|
89
92
|
# Encoding.list.map{|e| [e.to_s.upcase==fix_encoding(e.to_s.downcase.gsub("-", "")), e.to_s] }.select {|a,b| !b}
|
|
90
93
|
# Encoding.list.map{|e| [e.to_s==fix_encoding(e.to_s), e.to_s] }.select {|a,b| !b}
|
|
91
94
|
def Ruby19.fix_encoding(encoding)
|
|
@@ -94,8 +97,8 @@ module Mail
|
|
|
94
97
|
when /iso-?(\d{4})-?(\w{1,2})/i then return "ISO-#{$1}-#{$2}"
|
|
95
98
|
# "ISO-2022-JP-KDDI" and alike
|
|
96
99
|
when /iso-?(\d{4})-?(\w{1,2})-?(\w*)/i then return "ISO-#{$1}-#{$2}-#{$3}"
|
|
97
|
-
#
|
|
98
|
-
when /utf-?(
|
|
100
|
+
# UTF-8, UTF-32BE and alike
|
|
101
|
+
when /utf-?(\d{1,2})?(\w{1,2})/i then return "UTF-#{$1}#{$2}"
|
|
99
102
|
# Windows-1252 and alike
|
|
100
103
|
when /Windows-?(.*)/i then return "Windows-#{$1}"
|
|
101
104
|
#more aliases to be added if needed
|
data/lib/mail.rb
CHANGED
|
@@ -4,12 +4,6 @@ module Mail # :doc:
|
|
|
4
4
|
require 'date'
|
|
5
5
|
require 'shellwords'
|
|
6
6
|
|
|
7
|
-
require 'active_support'
|
|
8
|
-
require 'active_support/core_ext/class/attribute_accessors'
|
|
9
|
-
require 'active_support/core_ext/hash/indifferent_access'
|
|
10
|
-
require 'active_support/core_ext/object/blank'
|
|
11
|
-
require 'active_support/core_ext/string'
|
|
12
|
-
|
|
13
7
|
require 'uri'
|
|
14
8
|
require 'net/smtp'
|
|
15
9
|
require 'mime/types'
|
|
@@ -22,7 +16,7 @@ module Mail # :doc:
|
|
|
22
16
|
end
|
|
23
17
|
end
|
|
24
18
|
|
|
25
|
-
if RUBY_VERSION >= "1.9.
|
|
19
|
+
if RUBY_VERSION >= "1.9.0"
|
|
26
20
|
require 'mail/version_specific/ruby_1_9'
|
|
27
21
|
RubyVer = Ruby19
|
|
28
22
|
else
|
|
@@ -33,9 +27,20 @@ module Mail # :doc:
|
|
|
33
27
|
require 'mail/version'
|
|
34
28
|
|
|
35
29
|
require 'mail/core_extensions/nil'
|
|
30
|
+
require 'mail/core_extensions/object'
|
|
36
31
|
require 'mail/core_extensions/string'
|
|
37
32
|
require 'mail/core_extensions/shellwords' unless String.new.respond_to?(:shellescape)
|
|
38
33
|
require 'mail/core_extensions/smtp' if RUBY_VERSION < '1.9.3'
|
|
34
|
+
require 'mail/indifferent_hash'
|
|
35
|
+
|
|
36
|
+
# Only load our multibyte extensions if AS is not already loaded
|
|
37
|
+
if defined?(ActiveSupport)
|
|
38
|
+
require 'active_support/inflector'
|
|
39
|
+
else
|
|
40
|
+
require 'mail/core_extensions/string/access'
|
|
41
|
+
require 'mail/core_extensions/string/multibyte'
|
|
42
|
+
require 'mail/multibyte'
|
|
43
|
+
end
|
|
39
44
|
|
|
40
45
|
require 'mail/patterns'
|
|
41
46
|
require 'mail/utilities'
|
metadata
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: mail
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
|
|
4
|
+
hash: 3
|
|
5
|
+
prerelease:
|
|
5
6
|
segments:
|
|
6
7
|
- 2
|
|
7
|
-
-
|
|
8
|
-
-
|
|
9
|
-
version: 2.
|
|
8
|
+
- 3
|
|
9
|
+
- 0
|
|
10
|
+
version: 2.3.0
|
|
10
11
|
platform: ruby
|
|
11
12
|
authors:
|
|
12
13
|
- Mikel Lindsaar
|
|
@@ -14,68 +15,56 @@ autorequire:
|
|
|
14
15
|
bindir: bin
|
|
15
16
|
cert_chain: []
|
|
16
17
|
|
|
17
|
-
date: 2011-
|
|
18
|
+
date: 2011-04-26 00:00:00 +10:00
|
|
18
19
|
default_executable:
|
|
19
20
|
dependencies:
|
|
20
|
-
- !ruby/object:Gem::Dependency
|
|
21
|
-
name: activesupport
|
|
22
|
-
prerelease: false
|
|
23
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
|
24
|
-
none: false
|
|
25
|
-
requirements:
|
|
26
|
-
- - ">="
|
|
27
|
-
- !ruby/object:Gem::Version
|
|
28
|
-
segments:
|
|
29
|
-
- 2
|
|
30
|
-
- 3
|
|
31
|
-
- 6
|
|
32
|
-
version: 2.3.6
|
|
33
|
-
type: :runtime
|
|
34
|
-
version_requirements: *id001
|
|
35
21
|
- !ruby/object:Gem::Dependency
|
|
36
22
|
name: mime-types
|
|
37
23
|
prerelease: false
|
|
38
|
-
requirement: &
|
|
24
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
|
39
25
|
none: false
|
|
40
26
|
requirements:
|
|
41
27
|
- - ~>
|
|
42
28
|
- !ruby/object:Gem::Version
|
|
29
|
+
hash: 47
|
|
43
30
|
segments:
|
|
44
31
|
- 1
|
|
45
32
|
- 16
|
|
46
33
|
version: "1.16"
|
|
47
34
|
type: :runtime
|
|
48
|
-
version_requirements: *
|
|
35
|
+
version_requirements: *id001
|
|
49
36
|
- !ruby/object:Gem::Dependency
|
|
50
37
|
name: treetop
|
|
51
38
|
prerelease: false
|
|
52
|
-
requirement: &
|
|
39
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
|
53
40
|
none: false
|
|
54
41
|
requirements:
|
|
55
42
|
- - ~>
|
|
56
43
|
- !ruby/object:Gem::Version
|
|
44
|
+
hash: 23
|
|
57
45
|
segments:
|
|
58
46
|
- 1
|
|
59
47
|
- 4
|
|
60
48
|
- 8
|
|
61
49
|
version: 1.4.8
|
|
62
50
|
type: :runtime
|
|
63
|
-
version_requirements: *
|
|
51
|
+
version_requirements: *id002
|
|
64
52
|
- !ruby/object:Gem::Dependency
|
|
65
53
|
name: i18n
|
|
66
54
|
prerelease: false
|
|
67
|
-
requirement: &
|
|
55
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
|
68
56
|
none: false
|
|
69
57
|
requirements:
|
|
70
58
|
- - ">="
|
|
71
59
|
- !ruby/object:Gem::Version
|
|
60
|
+
hash: 15
|
|
72
61
|
segments:
|
|
73
62
|
- 0
|
|
74
63
|
- 4
|
|
75
64
|
- 0
|
|
76
65
|
version: 0.4.0
|
|
77
66
|
type: :runtime
|
|
78
|
-
version_requirements: *
|
|
67
|
+
version_requirements: *id003
|
|
79
68
|
description: A really Ruby Mail handler.
|
|
80
69
|
email: raasdnil@gmail.com
|
|
81
70
|
executables: []
|
|
@@ -88,14 +77,20 @@ extra_rdoc_files:
|
|
|
88
77
|
- TODO.rdoc
|
|
89
78
|
files:
|
|
90
79
|
- README.rdoc
|
|
80
|
+
- CHANGELOG.rdoc
|
|
81
|
+
- Dependencies.txt
|
|
82
|
+
- Gemfile
|
|
91
83
|
- Rakefile
|
|
92
84
|
- TODO.rdoc
|
|
93
85
|
- lib/mail/attachments_list.rb
|
|
94
86
|
- lib/mail/body.rb
|
|
95
87
|
- lib/mail/configuration.rb
|
|
96
88
|
- lib/mail/core_extensions/nil.rb
|
|
89
|
+
- lib/mail/core_extensions/object.rb
|
|
97
90
|
- lib/mail/core_extensions/shellwords.rb
|
|
98
91
|
- lib/mail/core_extensions/smtp.rb
|
|
92
|
+
- lib/mail/core_extensions/string/access.rb
|
|
93
|
+
- lib/mail/core_extensions/string/multibyte.rb
|
|
99
94
|
- lib/mail/core_extensions/string.rb
|
|
100
95
|
- lib/mail/elements/address.rb
|
|
101
96
|
- lib/mail/elements/address_list.rb
|
|
@@ -160,11 +155,18 @@ files:
|
|
|
160
155
|
- lib/mail/fields/unstructured_field.rb
|
|
161
156
|
- lib/mail/fields.rb
|
|
162
157
|
- lib/mail/header.rb
|
|
158
|
+
- lib/mail/indifferent_hash.rb
|
|
163
159
|
- lib/mail/mail.rb
|
|
164
160
|
- lib/mail/message.rb
|
|
161
|
+
- lib/mail/multibyte/chars.rb
|
|
162
|
+
- lib/mail/multibyte/exceptions.rb
|
|
163
|
+
- lib/mail/multibyte/unicode.rb
|
|
164
|
+
- lib/mail/multibyte/utils.rb
|
|
165
|
+
- lib/mail/multibyte.rb
|
|
165
166
|
- lib/mail/network/delivery_methods/file_delivery.rb
|
|
166
167
|
- lib/mail/network/delivery_methods/sendmail.rb
|
|
167
168
|
- lib/mail/network/delivery_methods/smtp.rb
|
|
169
|
+
- lib/mail/network/delivery_methods/smtp_connection.rb
|
|
168
170
|
- lib/mail/network/delivery_methods/test_mailer.rb
|
|
169
171
|
- lib/mail/network/retriever_methods/base.rb
|
|
170
172
|
- lib/mail/network/retriever_methods/imap.rb
|
|
@@ -210,7 +212,6 @@ files:
|
|
|
210
212
|
- lib/tasks/corpus.rake
|
|
211
213
|
- lib/tasks/treetop.rake
|
|
212
214
|
- lib/VERSION
|
|
213
|
-
- CHANGELOG.rdoc
|
|
214
215
|
has_rdoc: true
|
|
215
216
|
homepage: http://github.com/mikel/mail
|
|
216
217
|
licenses: []
|
|
@@ -225,6 +226,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
225
226
|
requirements:
|
|
226
227
|
- - ">="
|
|
227
228
|
- !ruby/object:Gem::Version
|
|
229
|
+
hash: 3
|
|
228
230
|
segments:
|
|
229
231
|
- 0
|
|
230
232
|
version: "0"
|
|
@@ -233,13 +235,14 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
233
235
|
requirements:
|
|
234
236
|
- - ">="
|
|
235
237
|
- !ruby/object:Gem::Version
|
|
238
|
+
hash: 3
|
|
236
239
|
segments:
|
|
237
240
|
- 0
|
|
238
241
|
version: "0"
|
|
239
242
|
requirements: []
|
|
240
243
|
|
|
241
244
|
rubyforge_project:
|
|
242
|
-
rubygems_version: 1.
|
|
245
|
+
rubygems_version: 1.6.2
|
|
243
246
|
signing_key:
|
|
244
247
|
specification_version: 3
|
|
245
248
|
summary: Mail provides a nice Ruby DSL for making, sending and reading emails.
|