mail 2.6.1 → 2.6.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.rdoc +8 -1
- data/README.md +5 -5
- data/lib/mail.rb +3 -2
- data/lib/mail/body.rb +28 -4
- data/lib/mail/{patterns.rb → constants.rb} +22 -4
- data/lib/mail/core_extensions/string.rb +5 -2
- data/lib/mail/elements/address.rb +49 -72
- data/lib/mail/elements/address_list.rb +1 -11
- data/lib/mail/encodings.rb +11 -26
- data/lib/mail/encodings/unix_to_unix.rb +17 -0
- data/lib/mail/field.rb +2 -2
- data/lib/mail/field_list.rb +1 -1
- data/lib/mail/fields/common/common_field.rb +2 -1
- data/lib/mail/fields/common/parameter_hash.rb +3 -3
- data/lib/mail/fields/unstructured_field.rb +3 -3
- data/lib/mail/header.rb +3 -2
- data/lib/mail/mail.rb +3 -1
- data/lib/mail/matchers/has_sent_mail.rb +2 -2
- data/lib/mail/message.rb +10 -5
- data/lib/mail/parsers/content_type_parser.rb +4 -2
- data/lib/mail/parsers/ragel/common.rl +2 -1
- data/lib/mail/parsers/ragel/ruby.rb +4 -3
- data/lib/mail/parsers/ragel/ruby/machines/envelope_from_machine.rb +1439 -1419
- data/lib/mail/utilities.rb +3 -3
- data/lib/mail/version.rb +7 -15
- data/lib/mail/version_specific/ruby_1_8.rb +2 -2
- data/lib/mail/version_specific/ruby_1_9.rb +48 -14
- metadata +36 -36
- data/VERSION +0 -4
data/lib/mail/utilities.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
module Mail
|
3
3
|
module Utilities
|
4
|
-
include
|
4
|
+
include Constants
|
5
5
|
|
6
6
|
# Returns true if the string supplied is free from characters not allowed as an ATOM
|
7
7
|
def atom_safe?( str )
|
@@ -177,7 +177,7 @@ module Mail
|
|
177
177
|
# string = :resent_from_field
|
178
178
|
# dasherize ( string ) #=> 'resent_from_field'
|
179
179
|
def dasherize( str )
|
180
|
-
str.to_s.
|
180
|
+
str.to_s.tr(UNDERSCORE, HYPHEN)
|
181
181
|
end
|
182
182
|
|
183
183
|
# Swaps out all hyphens (-) for underscores (_) good for stringing to symbols
|
@@ -188,7 +188,7 @@ module Mail
|
|
188
188
|
# string = :resent_from_field
|
189
189
|
# underscoreize ( string ) #=> 'resent_from_field'
|
190
190
|
def underscoreize( str )
|
191
|
-
str.to_s.downcase.
|
191
|
+
str.to_s.downcase.tr(HYPHEN, UNDERSCORE)
|
192
192
|
end
|
193
193
|
|
194
194
|
if RUBY_VERSION <= '1.8.6'
|
data/lib/mail/version.rb
CHANGED
@@ -1,24 +1,16 @@
|
|
1
|
-
# encoding: utf-8
|
2
1
|
module Mail
|
3
2
|
module VERSION
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
version[type] = value
|
10
|
-
end
|
11
|
-
|
12
|
-
MAJOR = version['major']
|
13
|
-
MINOR = version['minor']
|
14
|
-
PATCH = version['patch']
|
15
|
-
BUILD = version['build']
|
3
|
+
|
4
|
+
MAJOR = 2
|
5
|
+
MINOR = 6
|
6
|
+
PATCH = 3
|
7
|
+
BUILD = nil
|
16
8
|
|
17
9
|
STRING = [MAJOR, MINOR, PATCH, BUILD].compact.join('.')
|
18
|
-
|
10
|
+
|
19
11
|
def self.version
|
20
12
|
STRING
|
21
13
|
end
|
22
|
-
|
14
|
+
|
23
15
|
end
|
24
16
|
end
|
@@ -62,7 +62,7 @@ module Mail
|
|
62
62
|
end
|
63
63
|
|
64
64
|
def Ruby18.b_value_decode(str)
|
65
|
-
match = str.match(/\=\?(.+)?\?[Bb]\?(
|
65
|
+
match = str.match(/\=\?(.+)?\?[Bb]\?(.*)\?\=/m)
|
66
66
|
if match
|
67
67
|
encoding = match[1]
|
68
68
|
str = Ruby18.decode_base64(match[2])
|
@@ -79,7 +79,7 @@ module Mail
|
|
79
79
|
end
|
80
80
|
|
81
81
|
def Ruby18.q_value_decode(str)
|
82
|
-
match = str.match(/\=\?(.+)?\?[Qq]\?(
|
82
|
+
match = str.match(/\=\?(.+)?\?[Qq]\?(.*)\?\=/m)
|
83
83
|
if match
|
84
84
|
encoding = match[1]
|
85
85
|
string = match[2].gsub(/_/, '=20')
|
@@ -2,6 +2,36 @@
|
|
2
2
|
|
3
3
|
module Mail
|
4
4
|
class Ruby19
|
5
|
+
class StrictCharsetEncoder
|
6
|
+
def encode(string, charset)
|
7
|
+
string.force_encoding(Mail::Ruby19.pick_encoding(charset))
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
class BestEffortCharsetEncoder
|
12
|
+
def encode(string, charset)
|
13
|
+
string.force_encoding(pick_encoding(charset))
|
14
|
+
end
|
15
|
+
|
16
|
+
private
|
17
|
+
|
18
|
+
def pick_encoding(charset)
|
19
|
+
charset = case charset
|
20
|
+
when /ansi_x3.110-1983/
|
21
|
+
'ISO-8859-1'
|
22
|
+
when /Windows-?1258/i # Windows-1258 is similar to 1252
|
23
|
+
"Windows-1252"
|
24
|
+
else
|
25
|
+
charset
|
26
|
+
end
|
27
|
+
Mail::Ruby19.pick_encoding(charset)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
class << self
|
32
|
+
attr_accessor :charset_encoder
|
33
|
+
end
|
34
|
+
self.charset_encoder = StrictCharsetEncoder.new
|
5
35
|
|
6
36
|
# Escapes any parenthesis in a string that are unescaped this uses
|
7
37
|
# a Ruby 1.9.1 regexp feature of negative look behind
|
@@ -49,14 +79,17 @@ module Mail
|
|
49
79
|
end
|
50
80
|
|
51
81
|
def Ruby19.b_value_decode(str)
|
52
|
-
match = str.match(/\=\?(.+)?\?[Bb]\?(
|
82
|
+
match = str.match(/\=\?(.+)?\?[Bb]\?(.*)\?\=/m)
|
53
83
|
if match
|
54
84
|
charset = match[1]
|
55
85
|
str = Ruby19.decode_base64(match[2])
|
56
|
-
str.
|
86
|
+
str = charset_encoder.encode(str, charset)
|
57
87
|
end
|
58
|
-
decoded = str.encode(
|
59
|
-
decoded.valid_encoding? ? decoded : decoded.encode(
|
88
|
+
decoded = str.encode(Encoding::UTF_8, :invalid => :replace, :replace => "")
|
89
|
+
decoded.valid_encoding? ? decoded : decoded.encode(Encoding::UTF_16LE, :invalid => :replace, :replace => "").encode(Encoding::UTF_8)
|
90
|
+
rescue Encoding::UndefinedConversionError, ArgumentError, Encoding::ConverterNotFoundError
|
91
|
+
warn "Encoding conversion failed #{$!}"
|
92
|
+
str.dup.force_encoding(Encoding::UTF_8)
|
60
93
|
end
|
61
94
|
|
62
95
|
def Ruby19.q_value_encode(str, encoding = nil)
|
@@ -65,28 +98,29 @@ module Mail
|
|
65
98
|
end
|
66
99
|
|
67
100
|
def Ruby19.q_value_decode(str)
|
68
|
-
match = str.match(/\=\?(.+)?\?[Qq]\?(
|
101
|
+
match = str.match(/\=\?(.+)?\?[Qq]\?(.*)\?\=/m)
|
69
102
|
if match
|
70
103
|
charset = match[1]
|
71
104
|
string = match[2].gsub(/_/, '=20')
|
72
105
|
# Remove trailing = if it exists in a Q encoding
|
73
106
|
string = string.sub(/\=$/, '')
|
74
107
|
str = Encodings::QuotedPrintable.decode(string)
|
75
|
-
str.
|
108
|
+
str = charset_encoder.encode(str, charset)
|
76
109
|
# We assume that binary strings hold utf-8 directly to work around
|
77
110
|
# jruby/jruby#829 which subtly changes String#encode semantics.
|
78
|
-
str.force_encoding(
|
111
|
+
str.force_encoding(Encoding::UTF_8) if str.encoding == Encoding::ASCII_8BIT
|
79
112
|
end
|
80
|
-
decoded = str.encode(
|
81
|
-
decoded.valid_encoding? ? decoded : decoded.encode(
|
82
|
-
rescue Encoding::UndefinedConversionError
|
83
|
-
|
113
|
+
decoded = str.encode(Encoding::UTF_8, :invalid => :replace, :replace => "")
|
114
|
+
decoded.valid_encoding? ? decoded : decoded.encode(Encoding::UTF_16LE, :invalid => :replace, :replace => "").encode(Encoding::UTF_8)
|
115
|
+
rescue Encoding::UndefinedConversionError, ArgumentError, Encoding::ConverterNotFoundError
|
116
|
+
warn "Encoding conversion failed #{$!}"
|
117
|
+
str.dup.force_encoding(Encoding::UTF_8)
|
84
118
|
end
|
85
119
|
|
86
120
|
def Ruby19.param_decode(str, encoding)
|
87
|
-
|
88
|
-
|
89
|
-
|
121
|
+
str = uri_parser.unescape(str)
|
122
|
+
str = charset_encoder.encode(str, encoding) if encoding
|
123
|
+
str
|
90
124
|
end
|
91
125
|
|
92
126
|
def Ruby19.param_encode(str)
|
metadata
CHANGED
@@ -1,89 +1,89 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mail
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.6.
|
4
|
+
version: 2.6.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mikel Lindsaar
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-11-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: mime-types
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '1.16'
|
20
|
-
- - <
|
20
|
+
- - "<"
|
21
21
|
- !ruby/object:Gem::Version
|
22
22
|
version: '3'
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
25
|
version_requirements: !ruby/object:Gem::Requirement
|
26
26
|
requirements:
|
27
|
-
- -
|
27
|
+
- - ">="
|
28
28
|
- !ruby/object:Gem::Version
|
29
29
|
version: '1.16'
|
30
|
-
- - <
|
30
|
+
- - "<"
|
31
31
|
- !ruby/object:Gem::Version
|
32
32
|
version: '3'
|
33
33
|
- !ruby/object:Gem::Dependency
|
34
34
|
name: bundler
|
35
35
|
requirement: !ruby/object:Gem::Requirement
|
36
36
|
requirements:
|
37
|
-
- -
|
37
|
+
- - ">="
|
38
38
|
- !ruby/object:Gem::Version
|
39
39
|
version: 1.0.3
|
40
40
|
type: :development
|
41
41
|
prerelease: false
|
42
42
|
version_requirements: !ruby/object:Gem::Requirement
|
43
43
|
requirements:
|
44
|
-
- -
|
44
|
+
- - ">="
|
45
45
|
- !ruby/object:Gem::Version
|
46
46
|
version: 1.0.3
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: rake
|
49
49
|
requirement: !ruby/object:Gem::Requirement
|
50
50
|
requirements:
|
51
|
-
- -
|
51
|
+
- - ">"
|
52
52
|
- !ruby/object:Gem::Version
|
53
53
|
version: 0.8.7
|
54
54
|
type: :development
|
55
55
|
prerelease: false
|
56
56
|
version_requirements: !ruby/object:Gem::Requirement
|
57
57
|
requirements:
|
58
|
-
- -
|
58
|
+
- - ">"
|
59
59
|
- !ruby/object:Gem::Version
|
60
60
|
version: 0.8.7
|
61
61
|
- !ruby/object:Gem::Dependency
|
62
62
|
name: rspec
|
63
63
|
requirement: !ruby/object:Gem::Requirement
|
64
64
|
requirements:
|
65
|
-
- - ~>
|
65
|
+
- - "~>"
|
66
66
|
- !ruby/object:Gem::Version
|
67
|
-
version:
|
67
|
+
version: 3.0.0
|
68
68
|
type: :development
|
69
69
|
prerelease: false
|
70
70
|
version_requirements: !ruby/object:Gem::Requirement
|
71
71
|
requirements:
|
72
|
-
- - ~>
|
72
|
+
- - "~>"
|
73
73
|
- !ruby/object:Gem::Version
|
74
|
-
version:
|
74
|
+
version: 3.0.0
|
75
75
|
- !ruby/object:Gem::Dependency
|
76
76
|
name: rdoc
|
77
77
|
requirement: !ruby/object:Gem::Requirement
|
78
78
|
requirements:
|
79
|
-
- -
|
79
|
+
- - ">="
|
80
80
|
- !ruby/object:Gem::Version
|
81
81
|
version: '0'
|
82
82
|
type: :development
|
83
83
|
prerelease: false
|
84
84
|
version_requirements: !ruby/object:Gem::Requirement
|
85
85
|
requirements:
|
86
|
-
- -
|
86
|
+
- - ">="
|
87
87
|
- !ruby/object:Gem::Version
|
88
88
|
version: '0'
|
89
89
|
description: A really Ruby Mail handler.
|
@@ -96,25 +96,27 @@ extra_rdoc_files:
|
|
96
96
|
- CHANGELOG.rdoc
|
97
97
|
- TODO.rdoc
|
98
98
|
files:
|
99
|
-
- README.md
|
100
|
-
- VERSION
|
101
|
-
- MIT-LICENSE
|
102
|
-
- CONTRIBUTING.md
|
103
99
|
- CHANGELOG.rdoc
|
100
|
+
- CONTRIBUTING.md
|
104
101
|
- Dependencies.txt
|
105
102
|
- Gemfile
|
103
|
+
- MIT-LICENSE
|
104
|
+
- README.md
|
106
105
|
- Rakefile
|
107
106
|
- TODO.rdoc
|
107
|
+
- lib/mail.rb
|
108
108
|
- lib/mail/attachments_list.rb
|
109
109
|
- lib/mail/body.rb
|
110
110
|
- lib/mail/check_delivery_params.rb
|
111
111
|
- lib/mail/configuration.rb
|
112
|
+
- lib/mail/constants.rb
|
112
113
|
- lib/mail/core_extensions/nil.rb
|
113
114
|
- lib/mail/core_extensions/object.rb
|
114
115
|
- lib/mail/core_extensions/smtp.rb
|
116
|
+
- lib/mail/core_extensions/string.rb
|
115
117
|
- lib/mail/core_extensions/string/access.rb
|
116
118
|
- lib/mail/core_extensions/string/multibyte.rb
|
117
|
-
- lib/mail/
|
119
|
+
- lib/mail/elements.rb
|
118
120
|
- lib/mail/elements/address.rb
|
119
121
|
- lib/mail/elements/address_list.rb
|
120
122
|
- lib/mail/elements/content_disposition_element.rb
|
@@ -127,17 +129,18 @@ files:
|
|
127
129
|
- lib/mail/elements/mime_version_element.rb
|
128
130
|
- lib/mail/elements/phrase_list.rb
|
129
131
|
- lib/mail/elements/received_element.rb
|
130
|
-
- lib/mail/
|
132
|
+
- lib/mail/encodings.rb
|
131
133
|
- lib/mail/encodings/7bit.rb
|
132
134
|
- lib/mail/encodings/8bit.rb
|
133
135
|
- lib/mail/encodings/base64.rb
|
134
136
|
- lib/mail/encodings/binary.rb
|
135
137
|
- lib/mail/encodings/quoted_printable.rb
|
136
138
|
- lib/mail/encodings/transfer_encoding.rb
|
137
|
-
- lib/mail/encodings.rb
|
139
|
+
- lib/mail/encodings/unix_to_unix.rb
|
138
140
|
- lib/mail/envelope.rb
|
139
141
|
- lib/mail/field.rb
|
140
142
|
- lib/mail/field_list.rb
|
143
|
+
- lib/mail/fields.rb
|
141
144
|
- lib/mail/fields/bcc_field.rb
|
142
145
|
- lib/mail/fields/cc_field.rb
|
143
146
|
- lib/mail/fields/comments_field.rb
|
@@ -176,17 +179,17 @@ files:
|
|
176
179
|
- lib/mail/fields/subject_field.rb
|
177
180
|
- lib/mail/fields/to_field.rb
|
178
181
|
- lib/mail/fields/unstructured_field.rb
|
179
|
-
- lib/mail/fields.rb
|
180
182
|
- lib/mail/header.rb
|
181
183
|
- lib/mail/indifferent_hash.rb
|
182
184
|
- lib/mail/mail.rb
|
183
185
|
- lib/mail/matchers/has_sent_mail.rb
|
184
186
|
- lib/mail/message.rb
|
187
|
+
- lib/mail/multibyte.rb
|
185
188
|
- lib/mail/multibyte/chars.rb
|
186
189
|
- lib/mail/multibyte/exceptions.rb
|
187
190
|
- lib/mail/multibyte/unicode.rb
|
188
191
|
- lib/mail/multibyte/utils.rb
|
189
|
-
- lib/mail/
|
192
|
+
- lib/mail/network.rb
|
190
193
|
- lib/mail/network/delivery_methods/exim.rb
|
191
194
|
- lib/mail/network/delivery_methods/file_delivery.rb
|
192
195
|
- lib/mail/network/delivery_methods/sendmail.rb
|
@@ -197,7 +200,7 @@ files:
|
|
197
200
|
- lib/mail/network/retriever_methods/imap.rb
|
198
201
|
- lib/mail/network/retriever_methods/pop3.rb
|
199
202
|
- lib/mail/network/retriever_methods/test_retriever.rb
|
200
|
-
- lib/mail/
|
203
|
+
- lib/mail/parsers.rb
|
201
204
|
- lib/mail/parsers/address_lists_parser.rb
|
202
205
|
- lib/mail/parsers/content_disposition_parser.rb
|
203
206
|
- lib/mail/parsers/content_location_parser.rb
|
@@ -208,9 +211,11 @@ files:
|
|
208
211
|
- lib/mail/parsers/message_ids_parser.rb
|
209
212
|
- lib/mail/parsers/mime_version_parser.rb
|
210
213
|
- lib/mail/parsers/phrase_lists_parser.rb
|
214
|
+
- lib/mail/parsers/ragel.rb
|
211
215
|
- lib/mail/parsers/ragel/common.rl
|
212
216
|
- lib/mail/parsers/ragel/date_time.rl
|
213
217
|
- lib/mail/parsers/ragel/parser_info.rb
|
218
|
+
- lib/mail/parsers/ragel/ruby.rb
|
214
219
|
- lib/mail/parsers/ragel/ruby/machines/address_lists_machine.rb
|
215
220
|
- lib/mail/parsers/ragel/ruby/machines/address_lists_machine.rb.rl
|
216
221
|
- lib/mail/parsers/ragel/ruby/machines/content_disposition_machine.rb
|
@@ -235,42 +240,37 @@ files:
|
|
235
240
|
- lib/mail/parsers/ragel/ruby/machines/received_machine.rb
|
236
241
|
- lib/mail/parsers/ragel/ruby/machines/received_machine.rb.rl
|
237
242
|
- lib/mail/parsers/ragel/ruby/parser.rb.rl.erb
|
238
|
-
- lib/mail/parsers/ragel/ruby.rb
|
239
|
-
- lib/mail/parsers/ragel.rb
|
240
243
|
- lib/mail/parsers/received_parser.rb
|
241
|
-
- lib/mail/parsers.rb
|
242
244
|
- lib/mail/part.rb
|
243
245
|
- lib/mail/parts_list.rb
|
244
|
-
- lib/mail/patterns.rb
|
245
246
|
- lib/mail/utilities.rb
|
246
247
|
- lib/mail/values/unicode_tables.dat
|
247
248
|
- lib/mail/version.rb
|
248
249
|
- lib/mail/version_specific/ruby_1_8.rb
|
249
250
|
- lib/mail/version_specific/ruby_1_9.rb
|
250
|
-
|
251
|
-
homepage: http://github.com/mikel/mail
|
251
|
+
homepage: https://github.com/mikel/mail
|
252
252
|
licenses:
|
253
253
|
- MIT
|
254
254
|
metadata: {}
|
255
255
|
post_install_message:
|
256
256
|
rdoc_options:
|
257
|
-
- --exclude
|
257
|
+
- "--exclude"
|
258
258
|
- lib/mail/values/unicode_tables.dat
|
259
259
|
require_paths:
|
260
260
|
- lib
|
261
261
|
required_ruby_version: !ruby/object:Gem::Requirement
|
262
262
|
requirements:
|
263
|
-
- -
|
263
|
+
- - ">="
|
264
264
|
- !ruby/object:Gem::Version
|
265
265
|
version: '0'
|
266
266
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
267
267
|
requirements:
|
268
|
-
- -
|
268
|
+
- - ">="
|
269
269
|
- !ruby/object:Gem::Version
|
270
270
|
version: '0'
|
271
271
|
requirements: []
|
272
272
|
rubyforge_project:
|
273
|
-
rubygems_version: 2.
|
273
|
+
rubygems_version: 2.4.2
|
274
274
|
signing_key:
|
275
275
|
specification_version: 4
|
276
276
|
summary: Mail provides a nice Ruby DSL for making, sending and reading emails.
|
data/VERSION
DELETED