mail 2.6.4 → 2.7.0.rc1
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.
- checksums.yaml +4 -4
- data/CHANGELOG.rdoc +35 -0
- data/Dependencies.txt +0 -1
- data/Gemfile +7 -7
- data/README.md +8 -5
- data/Rakefile +0 -6
- data/lib/mail/attachments_list.rb +4 -3
- data/lib/mail/body.rb +3 -3
- data/lib/mail/check_delivery_params.rb +47 -10
- data/lib/mail/core_extensions/smtp.rb +19 -16
- data/lib/mail/core_extensions/string.rb +0 -4
- data/lib/mail/elements/address.rb +18 -8
- data/lib/mail/elements/address_list.rb +10 -18
- data/lib/mail/elements/content_disposition_element.rb +8 -15
- data/lib/mail/elements/content_location_element.rb +5 -10
- data/lib/mail/elements/content_transfer_encoding_element.rb +5 -10
- data/lib/mail/elements/content_type_element.rb +8 -19
- data/lib/mail/elements/date_time_element.rb +6 -14
- data/lib/mail/elements/envelope_from_element.rb +14 -21
- data/lib/mail/elements/message_ids_element.rb +8 -12
- data/lib/mail/elements/mime_version_element.rb +6 -14
- data/lib/mail/elements/phrase_list.rb +6 -9
- data/lib/mail/elements/received_element.rb +9 -15
- data/lib/mail/encodings.rb +12 -14
- data/lib/mail/field.rb +7 -4
- data/lib/mail/fields/common/address_container.rb +2 -2
- data/lib/mail/fields/common/parameter_hash.rb +1 -1
- data/lib/mail/fields/content_type_field.rb +2 -7
- data/lib/mail/fields/unstructured_field.rb +2 -2
- data/lib/mail/header.rb +1 -0
- data/lib/mail/message.rb +23 -25
- data/lib/mail/multibyte/chars.rb +29 -29
- data/lib/mail/multibyte.rb +51 -0
- data/lib/mail/network/delivery_methods/file_delivery.rb +4 -8
- data/lib/mail/network/delivery_methods/sendmail.rb +2 -4
- data/lib/mail/network/delivery_methods/smtp.rb +16 -11
- data/lib/mail/network/delivery_methods/smtp_connection.rb +2 -6
- data/lib/mail/network/delivery_methods/test_mailer.rb +5 -8
- data/lib/mail/network/retriever_methods/test_retriever.rb +1 -1
- data/lib/mail/parsers/address_lists_parser.rb +15321 -112
- data/lib/mail/parsers/address_lists_parser.rl +166 -0
- data/lib/mail/parsers/content_disposition_parser.rb +698 -55
- data/lib/mail/parsers/content_disposition_parser.rl +76 -0
- data/lib/mail/parsers/content_location_parser.rb +565 -23
- data/lib/mail/parsers/content_location_parser.rl +65 -0
- data/lib/mail/parsers/content_transfer_encoding_parser.rb +410 -22
- data/lib/mail/parsers/content_transfer_encoding_parser.rl +58 -0
- data/lib/mail/parsers/content_type_parser.rb +841 -54
- data/lib/mail/parsers/content_type_parser.rl +77 -0
- data/lib/mail/parsers/date_time_parser.rb +773 -26
- data/lib/mail/parsers/date_time_parser.rl +56 -0
- data/lib/mail/parsers/envelope_from_parser.rb +2051 -36
- data/lib/mail/parsers/envelope_from_parser.rl +76 -0
- data/lib/mail/parsers/message_ids_parser.rb +1494 -25
- data/lib/mail/parsers/message_ids_parser.rl +76 -0
- data/lib/mail/parsers/mime_version_parser.rb +393 -26
- data/lib/mail/parsers/mime_version_parser.rl +55 -0
- data/lib/mail/parsers/phrase_lists_parser.rb +529 -19
- data/lib/mail/parsers/phrase_lists_parser.rl +77 -0
- data/lib/mail/parsers/received_parser.rb +4711 -38
- data/lib/mail/parsers/received_parser.rl +78 -0
- data/lib/mail/parsers/rfc2045_content_transfer_encoding.rl +12 -0
- data/lib/mail/parsers/rfc2045_content_type.rl +24 -0
- data/lib/mail/parsers/rfc2045_mime.rl +15 -0
- data/lib/mail/parsers/rfc2183_content_disposition.rl +14 -0
- data/lib/mail/parsers/rfc5234_abnf_core_rules.rl +16 -0
- data/lib/mail/parsers/rfc5322.rl +57 -0
- data/lib/mail/parsers/rfc5322_address.rl +70 -0
- data/lib/mail/parsers/{ragel/date_time.rl → rfc5322_date_time.rl} +7 -1
- data/lib/mail/parsers/rfc5322_lexical_tokens.rl +56 -0
- data/lib/mail/parsers.rb +16 -24
- data/lib/mail/part.rb +1 -1
- data/lib/mail/parts_list.rb +5 -6
- data/lib/mail/utilities.rb +19 -3
- data/lib/mail/version.rb +3 -3
- data/lib/mail/version_specific/ruby_1_8.rb +28 -2
- data/lib/mail/version_specific/ruby_1_9.rb +51 -8
- data/lib/mail.rb +2 -10
- metadata +28 -45
- data/lib/mail/core_extensions/string/access.rb +0 -146
- data/lib/mail/core_extensions/string/multibyte.rb +0 -79
- data/lib/mail/parsers/ragel/common.rl +0 -185
- data/lib/mail/parsers/ragel/parser_info.rb +0 -61
- data/lib/mail/parsers/ragel/ruby/machines/address_lists_machine.rb +0 -14864
- data/lib/mail/parsers/ragel/ruby/machines/address_lists_machine.rb.rl +0 -37
- data/lib/mail/parsers/ragel/ruby/machines/content_disposition_machine.rb +0 -751
- data/lib/mail/parsers/ragel/ruby/machines/content_disposition_machine.rb.rl +0 -37
- data/lib/mail/parsers/ragel/ruby/machines/content_location_machine.rb +0 -614
- data/lib/mail/parsers/ragel/ruby/machines/content_location_machine.rb.rl +0 -37
- data/lib/mail/parsers/ragel/ruby/machines/content_transfer_encoding_machine.rb +0 -447
- data/lib/mail/parsers/ragel/ruby/machines/content_transfer_encoding_machine.rb.rl +0 -37
- data/lib/mail/parsers/ragel/ruby/machines/content_type_machine.rb +0 -825
- data/lib/mail/parsers/ragel/ruby/machines/content_type_machine.rb.rl +0 -37
- data/lib/mail/parsers/ragel/ruby/machines/date_time_machine.rb +0 -817
- data/lib/mail/parsers/ragel/ruby/machines/date_time_machine.rb.rl +0 -37
- data/lib/mail/parsers/ragel/ruby/machines/envelope_from_machine.rb +0 -2149
- data/lib/mail/parsers/ragel/ruby/machines/envelope_from_machine.rb.rl +0 -37
- data/lib/mail/parsers/ragel/ruby/machines/message_ids_machine.rb +0 -1570
- data/lib/mail/parsers/ragel/ruby/machines/message_ids_machine.rb.rl +0 -37
- data/lib/mail/parsers/ragel/ruby/machines/mime_version_machine.rb +0 -440
- data/lib/mail/parsers/ragel/ruby/machines/mime_version_machine.rb.rl +0 -37
- data/lib/mail/parsers/ragel/ruby/machines/phrase_lists_machine.rb +0 -564
- data/lib/mail/parsers/ragel/ruby/machines/phrase_lists_machine.rb.rl +0 -37
- data/lib/mail/parsers/ragel/ruby/machines/rb_actions.rl +0 -51
- data/lib/mail/parsers/ragel/ruby/machines/received_machine.rb +0 -5144
- data/lib/mail/parsers/ragel/ruby/machines/received_machine.rb.rl +0 -37
- data/lib/mail/parsers/ragel/ruby/parser.rb.rl.erb +0 -37
- data/lib/mail/parsers/ragel/ruby.rb +0 -40
- data/lib/mail/parsers/ragel.rb +0 -18
data/lib/mail.rb
CHANGED
|
@@ -7,13 +7,7 @@ module Mail # :doc:
|
|
|
7
7
|
|
|
8
8
|
require 'uri'
|
|
9
9
|
require 'net/smtp'
|
|
10
|
-
|
|
11
|
-
begin
|
|
12
|
-
# Use mime/types/columnar if available, for reduced memory usage
|
|
13
|
-
require 'mime/types/columnar'
|
|
14
|
-
rescue LoadError
|
|
15
|
-
require 'mime/types'
|
|
16
|
-
end
|
|
10
|
+
require 'mini_mime'
|
|
17
11
|
|
|
18
12
|
if RUBY_VERSION <= '1.8.6'
|
|
19
13
|
begin
|
|
@@ -34,15 +28,13 @@ module Mail # :doc:
|
|
|
34
28
|
require 'mail/version'
|
|
35
29
|
|
|
36
30
|
require 'mail/core_extensions/string'
|
|
37
|
-
require 'mail/core_extensions/smtp'
|
|
31
|
+
require 'mail/core_extensions/smtp'
|
|
38
32
|
require 'mail/indifferent_hash'
|
|
39
33
|
|
|
40
34
|
# Only load our multibyte extensions if AS is not already loaded
|
|
41
35
|
if defined?(ActiveSupport)
|
|
42
36
|
require 'active_support/inflector'
|
|
43
37
|
else
|
|
44
|
-
require 'mail/core_extensions/string/access'
|
|
45
|
-
require 'mail/core_extensions/string/multibyte'
|
|
46
38
|
require 'mail/multibyte'
|
|
47
39
|
end
|
|
48
40
|
|
metadata
CHANGED
|
@@ -1,35 +1,29 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: mail
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 2.
|
|
4
|
+
version: 2.7.0.rc1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Mikel Lindsaar
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2017-05-09 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
|
-
name:
|
|
14
|
+
name: mini_mime
|
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
|
16
16
|
requirements:
|
|
17
17
|
- - ">="
|
|
18
18
|
- !ruby/object:Gem::Version
|
|
19
|
-
version:
|
|
20
|
-
- - "<"
|
|
21
|
-
- !ruby/object:Gem::Version
|
|
22
|
-
version: '4'
|
|
19
|
+
version: 0.1.1
|
|
23
20
|
type: :runtime
|
|
24
21
|
prerelease: false
|
|
25
22
|
version_requirements: !ruby/object:Gem::Requirement
|
|
26
23
|
requirements:
|
|
27
24
|
- - ">="
|
|
28
25
|
- !ruby/object:Gem::Version
|
|
29
|
-
version:
|
|
30
|
-
- - "<"
|
|
31
|
-
- !ruby/object:Gem::Version
|
|
32
|
-
version: '4'
|
|
26
|
+
version: 0.1.1
|
|
33
27
|
- !ruby/object:Gem::Dependency
|
|
34
28
|
name: bundler
|
|
35
29
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -112,8 +106,6 @@ files:
|
|
|
112
106
|
- lib/mail/constants.rb
|
|
113
107
|
- lib/mail/core_extensions/smtp.rb
|
|
114
108
|
- lib/mail/core_extensions/string.rb
|
|
115
|
-
- lib/mail/core_extensions/string/access.rb
|
|
116
|
-
- lib/mail/core_extensions/string/multibyte.rb
|
|
117
109
|
- lib/mail/elements.rb
|
|
118
110
|
- lib/mail/elements/address.rb
|
|
119
111
|
- lib/mail/elements/address_list.rb
|
|
@@ -201,45 +193,36 @@ files:
|
|
|
201
193
|
- lib/mail/network/retriever_methods/test_retriever.rb
|
|
202
194
|
- lib/mail/parsers.rb
|
|
203
195
|
- lib/mail/parsers/address_lists_parser.rb
|
|
196
|
+
- lib/mail/parsers/address_lists_parser.rl
|
|
204
197
|
- lib/mail/parsers/content_disposition_parser.rb
|
|
198
|
+
- lib/mail/parsers/content_disposition_parser.rl
|
|
205
199
|
- lib/mail/parsers/content_location_parser.rb
|
|
200
|
+
- lib/mail/parsers/content_location_parser.rl
|
|
206
201
|
- lib/mail/parsers/content_transfer_encoding_parser.rb
|
|
202
|
+
- lib/mail/parsers/content_transfer_encoding_parser.rl
|
|
207
203
|
- lib/mail/parsers/content_type_parser.rb
|
|
204
|
+
- lib/mail/parsers/content_type_parser.rl
|
|
208
205
|
- lib/mail/parsers/date_time_parser.rb
|
|
206
|
+
- lib/mail/parsers/date_time_parser.rl
|
|
209
207
|
- lib/mail/parsers/envelope_from_parser.rb
|
|
208
|
+
- lib/mail/parsers/envelope_from_parser.rl
|
|
210
209
|
- lib/mail/parsers/message_ids_parser.rb
|
|
210
|
+
- lib/mail/parsers/message_ids_parser.rl
|
|
211
211
|
- lib/mail/parsers/mime_version_parser.rb
|
|
212
|
+
- lib/mail/parsers/mime_version_parser.rl
|
|
212
213
|
- lib/mail/parsers/phrase_lists_parser.rb
|
|
213
|
-
- lib/mail/parsers/
|
|
214
|
-
- lib/mail/parsers/ragel/common.rl
|
|
215
|
-
- lib/mail/parsers/ragel/date_time.rl
|
|
216
|
-
- lib/mail/parsers/ragel/parser_info.rb
|
|
217
|
-
- lib/mail/parsers/ragel/ruby.rb
|
|
218
|
-
- lib/mail/parsers/ragel/ruby/machines/address_lists_machine.rb
|
|
219
|
-
- lib/mail/parsers/ragel/ruby/machines/address_lists_machine.rb.rl
|
|
220
|
-
- lib/mail/parsers/ragel/ruby/machines/content_disposition_machine.rb
|
|
221
|
-
- lib/mail/parsers/ragel/ruby/machines/content_disposition_machine.rb.rl
|
|
222
|
-
- lib/mail/parsers/ragel/ruby/machines/content_location_machine.rb
|
|
223
|
-
- lib/mail/parsers/ragel/ruby/machines/content_location_machine.rb.rl
|
|
224
|
-
- lib/mail/parsers/ragel/ruby/machines/content_transfer_encoding_machine.rb
|
|
225
|
-
- lib/mail/parsers/ragel/ruby/machines/content_transfer_encoding_machine.rb.rl
|
|
226
|
-
- lib/mail/parsers/ragel/ruby/machines/content_type_machine.rb
|
|
227
|
-
- lib/mail/parsers/ragel/ruby/machines/content_type_machine.rb.rl
|
|
228
|
-
- lib/mail/parsers/ragel/ruby/machines/date_time_machine.rb
|
|
229
|
-
- lib/mail/parsers/ragel/ruby/machines/date_time_machine.rb.rl
|
|
230
|
-
- lib/mail/parsers/ragel/ruby/machines/envelope_from_machine.rb
|
|
231
|
-
- lib/mail/parsers/ragel/ruby/machines/envelope_from_machine.rb.rl
|
|
232
|
-
- lib/mail/parsers/ragel/ruby/machines/message_ids_machine.rb
|
|
233
|
-
- lib/mail/parsers/ragel/ruby/machines/message_ids_machine.rb.rl
|
|
234
|
-
- lib/mail/parsers/ragel/ruby/machines/mime_version_machine.rb
|
|
235
|
-
- lib/mail/parsers/ragel/ruby/machines/mime_version_machine.rb.rl
|
|
236
|
-
- lib/mail/parsers/ragel/ruby/machines/phrase_lists_machine.rb
|
|
237
|
-
- lib/mail/parsers/ragel/ruby/machines/phrase_lists_machine.rb.rl
|
|
238
|
-
- lib/mail/parsers/ragel/ruby/machines/rb_actions.rl
|
|
239
|
-
- lib/mail/parsers/ragel/ruby/machines/received_machine.rb
|
|
240
|
-
- lib/mail/parsers/ragel/ruby/machines/received_machine.rb.rl
|
|
241
|
-
- lib/mail/parsers/ragel/ruby/parser.rb.rl.erb
|
|
214
|
+
- lib/mail/parsers/phrase_lists_parser.rl
|
|
242
215
|
- lib/mail/parsers/received_parser.rb
|
|
216
|
+
- lib/mail/parsers/received_parser.rl
|
|
217
|
+
- lib/mail/parsers/rfc2045_content_transfer_encoding.rl
|
|
218
|
+
- lib/mail/parsers/rfc2045_content_type.rl
|
|
219
|
+
- lib/mail/parsers/rfc2045_mime.rl
|
|
220
|
+
- lib/mail/parsers/rfc2183_content_disposition.rl
|
|
221
|
+
- lib/mail/parsers/rfc5234_abnf_core_rules.rl
|
|
222
|
+
- lib/mail/parsers/rfc5322.rl
|
|
223
|
+
- lib/mail/parsers/rfc5322_address.rl
|
|
224
|
+
- lib/mail/parsers/rfc5322_date_time.rl
|
|
225
|
+
- lib/mail/parsers/rfc5322_lexical_tokens.rl
|
|
243
226
|
- lib/mail/part.rb
|
|
244
227
|
- lib/mail/parts_list.rb
|
|
245
228
|
- lib/mail/utilities.rb
|
|
@@ -264,12 +247,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
264
247
|
version: '0'
|
|
265
248
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
266
249
|
requirements:
|
|
267
|
-
- - "
|
|
250
|
+
- - ">"
|
|
268
251
|
- !ruby/object:Gem::Version
|
|
269
|
-
version:
|
|
252
|
+
version: 1.3.1
|
|
270
253
|
requirements: []
|
|
271
254
|
rubyforge_project:
|
|
272
|
-
rubygems_version: 2.
|
|
255
|
+
rubygems_version: 2.6.12
|
|
273
256
|
signing_key:
|
|
274
257
|
specification_version: 4
|
|
275
258
|
summary: Mail provides a nice Ruby DSL for making, sending and reading emails.
|
|
@@ -1,146 +0,0 @@
|
|
|
1
|
-
# encoding: utf-8
|
|
2
|
-
# frozen_string_literal: true
|
|
3
|
-
|
|
4
|
-
# This is not loaded if ActiveSupport is already loaded
|
|
5
|
-
|
|
6
|
-
# This is an almost cut and paste from ActiveSupport v3.0.6, copied in here so that Mail
|
|
7
|
-
# itself does not depend on ActiveSupport to avoid versioning conflicts
|
|
8
|
-
|
|
9
|
-
class String
|
|
10
|
-
unless '1.9'.respond_to?(:force_encoding)
|
|
11
|
-
# Returns the character at the +position+ treating the string as an array (where 0 is the first character).
|
|
12
|
-
#
|
|
13
|
-
# Examples:
|
|
14
|
-
# "hello".at(0) # => "h"
|
|
15
|
-
# "hello".at(4) # => "o"
|
|
16
|
-
# "hello".at(10) # => ERROR if < 1.9, nil in 1.9
|
|
17
|
-
def at(position)
|
|
18
|
-
mb_chars[position, 1].to_s
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
# Returns the remaining of the string from the +position+ treating the string as an array (where 0 is the first character).
|
|
22
|
-
#
|
|
23
|
-
# Examples:
|
|
24
|
-
# "hello".from(0) # => "hello"
|
|
25
|
-
# "hello".from(2) # => "llo"
|
|
26
|
-
# "hello".from(10) # => "" if < 1.9, nil in 1.9
|
|
27
|
-
def from(position)
|
|
28
|
-
mb_chars[position..-1].to_s
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
# Returns the beginning of the string up to the +position+ treating the string as an array (where 0 is the first character).
|
|
32
|
-
#
|
|
33
|
-
# Examples:
|
|
34
|
-
# "hello".to(0) # => "h"
|
|
35
|
-
# "hello".to(2) # => "hel"
|
|
36
|
-
# "hello".to(10) # => "hello"
|
|
37
|
-
def to(position)
|
|
38
|
-
mb_chars[0..position].to_s
|
|
39
|
-
end
|
|
40
|
-
|
|
41
|
-
# Returns the first character of the string or the first +limit+ characters.
|
|
42
|
-
#
|
|
43
|
-
# Examples:
|
|
44
|
-
# "hello".first # => "h"
|
|
45
|
-
# "hello".first(2) # => "he"
|
|
46
|
-
# "hello".first(10) # => "hello"
|
|
47
|
-
def first(limit = 1)
|
|
48
|
-
if limit == 0
|
|
49
|
-
''
|
|
50
|
-
elsif limit >= size
|
|
51
|
-
self
|
|
52
|
-
else
|
|
53
|
-
mb_chars[0...limit].to_s
|
|
54
|
-
end
|
|
55
|
-
end
|
|
56
|
-
|
|
57
|
-
# Returns the last character of the string or the last +limit+ characters.
|
|
58
|
-
#
|
|
59
|
-
# Examples:
|
|
60
|
-
# "hello".last # => "o"
|
|
61
|
-
# "hello".last(2) # => "lo"
|
|
62
|
-
# "hello".last(10) # => "hello"
|
|
63
|
-
def last(limit = 1)
|
|
64
|
-
if limit == 0
|
|
65
|
-
''
|
|
66
|
-
elsif limit >= size
|
|
67
|
-
self
|
|
68
|
-
else
|
|
69
|
-
mb_chars[(-limit)..-1].to_s
|
|
70
|
-
end
|
|
71
|
-
end
|
|
72
|
-
else
|
|
73
|
-
def at(position)
|
|
74
|
-
self[position]
|
|
75
|
-
end
|
|
76
|
-
|
|
77
|
-
def from(position)
|
|
78
|
-
self[position..-1]
|
|
79
|
-
end
|
|
80
|
-
|
|
81
|
-
def to(position)
|
|
82
|
-
self[0..position]
|
|
83
|
-
end
|
|
84
|
-
|
|
85
|
-
def first(limit = 1)
|
|
86
|
-
if limit == 0
|
|
87
|
-
''
|
|
88
|
-
elsif limit >= size
|
|
89
|
-
self
|
|
90
|
-
else
|
|
91
|
-
to(limit - 1)
|
|
92
|
-
end
|
|
93
|
-
end
|
|
94
|
-
|
|
95
|
-
def last(limit = 1)
|
|
96
|
-
if limit == 0
|
|
97
|
-
''
|
|
98
|
-
elsif limit >= size
|
|
99
|
-
self
|
|
100
|
-
else
|
|
101
|
-
from(-limit)
|
|
102
|
-
end
|
|
103
|
-
end
|
|
104
|
-
end
|
|
105
|
-
|
|
106
|
-
if Module.method(:const_get).arity == 1
|
|
107
|
-
# Tries to find a constant with the name specified in the argument string:
|
|
108
|
-
#
|
|
109
|
-
# "Module".constantize # => Module
|
|
110
|
-
# "Test::Unit".constantize # => Test::Unit
|
|
111
|
-
#
|
|
112
|
-
# The name is assumed to be the one of a top-level constant, no matter whether
|
|
113
|
-
# it starts with "::" or not. No lexical context is taken into account:
|
|
114
|
-
#
|
|
115
|
-
# C = 'outside'
|
|
116
|
-
# module M
|
|
117
|
-
# C = 'inside'
|
|
118
|
-
# C # => 'inside'
|
|
119
|
-
# "C".constantize # => 'outside', same as ::C
|
|
120
|
-
# end
|
|
121
|
-
#
|
|
122
|
-
# NameError is raised when the name is not in CamelCase or the constant is
|
|
123
|
-
# unknown.
|
|
124
|
-
def constantize
|
|
125
|
-
names = self.split('::')
|
|
126
|
-
names.shift if names.empty? || names.first.empty?
|
|
127
|
-
|
|
128
|
-
constant = Object
|
|
129
|
-
names.each do |name|
|
|
130
|
-
constant = constant.const_defined?(name) ? constant.const_get(name) : constant.const_missing(name)
|
|
131
|
-
end
|
|
132
|
-
constant
|
|
133
|
-
end
|
|
134
|
-
else
|
|
135
|
-
def constantize #:nodoc:
|
|
136
|
-
names = self.split('::')
|
|
137
|
-
names.shift if names.empty? || names.first.empty?
|
|
138
|
-
|
|
139
|
-
constant = Object
|
|
140
|
-
names.each do |name|
|
|
141
|
-
constant = constant.const_defined?(name, false) ? constant.const_get(name) : constant.const_missing(name)
|
|
142
|
-
end
|
|
143
|
-
constant
|
|
144
|
-
end
|
|
145
|
-
end
|
|
146
|
-
end
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
# encoding: utf-8
|
|
2
|
-
# frozen_string_literal: true
|
|
3
|
-
|
|
4
|
-
# This is not loaded if ActiveSupport is already loaded
|
|
5
|
-
|
|
6
|
-
# This is an almost cut and paste from ActiveSupport v3.0.6, copied in here so that Mail
|
|
7
|
-
# itself does not depend on ActiveSupport to avoid versioning conflicts
|
|
8
|
-
|
|
9
|
-
require 'mail/multibyte'
|
|
10
|
-
|
|
11
|
-
class String
|
|
12
|
-
if RUBY_VERSION >= "1.9"
|
|
13
|
-
# == Multibyte proxy
|
|
14
|
-
#
|
|
15
|
-
# +mb_chars+ is a multibyte safe proxy for string methods.
|
|
16
|
-
#
|
|
17
|
-
# In Ruby 1.8 and older it creates and returns an instance of the Mail::Multibyte::Chars class which
|
|
18
|
-
# encapsulates the original string. A Unicode safe version of all the String methods are defined on this proxy
|
|
19
|
-
# class. If the proxy class doesn't respond to a certain method, it's forwarded to the encapsuled string.
|
|
20
|
-
#
|
|
21
|
-
# name = 'Claus Müller'
|
|
22
|
-
# name.reverse # => "rell??M sualC"
|
|
23
|
-
# name.length # => 13
|
|
24
|
-
#
|
|
25
|
-
# name.mb_chars.reverse.to_s # => "rellüM sualC"
|
|
26
|
-
# name.mb_chars.length # => 12
|
|
27
|
-
#
|
|
28
|
-
# In Ruby 1.9 and newer +mb_chars+ returns +self+ because String is (mostly) encoding aware. This means that
|
|
29
|
-
# it becomes easy to run one version of your code on multiple Ruby versions.
|
|
30
|
-
#
|
|
31
|
-
# == Method chaining
|
|
32
|
-
#
|
|
33
|
-
# All the methods on the Chars proxy which normally return a string will return a Chars object. This allows
|
|
34
|
-
# method chaining on the result of any of these methods.
|
|
35
|
-
#
|
|
36
|
-
# name.mb_chars.reverse.length # => 12
|
|
37
|
-
#
|
|
38
|
-
# == Interoperability and configuration
|
|
39
|
-
#
|
|
40
|
-
# The Chars object tries to be as interchangeable with String objects as possible: sorting and comparing between
|
|
41
|
-
# String and Char work like expected. The bang! methods change the internal string representation in the Chars
|
|
42
|
-
# object. Interoperability problems can be resolved easily with a +to_s+ call.
|
|
43
|
-
#
|
|
44
|
-
# For more information about the methods defined on the Chars proxy see Mail::Multibyte::Chars. For
|
|
45
|
-
# information about how to change the default Multibyte behaviour see Mail::Multibyte.
|
|
46
|
-
def mb_chars
|
|
47
|
-
if Mail::Multibyte.proxy_class.consumes?(self)
|
|
48
|
-
Mail::Multibyte.proxy_class.new(self)
|
|
49
|
-
else
|
|
50
|
-
self
|
|
51
|
-
end
|
|
52
|
-
end
|
|
53
|
-
|
|
54
|
-
def is_utf8? #:nodoc
|
|
55
|
-
case encoding
|
|
56
|
-
when Encoding::UTF_8
|
|
57
|
-
valid_encoding?
|
|
58
|
-
when Encoding::ASCII_8BIT, Encoding::US_ASCII
|
|
59
|
-
dup.force_encoding(Encoding::UTF_8).valid_encoding?
|
|
60
|
-
else
|
|
61
|
-
false
|
|
62
|
-
end
|
|
63
|
-
end
|
|
64
|
-
else
|
|
65
|
-
def mb_chars
|
|
66
|
-
if Mail::Multibyte.proxy_class.wants?(self)
|
|
67
|
-
Mail::Multibyte.proxy_class.new(self)
|
|
68
|
-
else
|
|
69
|
-
self
|
|
70
|
-
end
|
|
71
|
-
end
|
|
72
|
-
|
|
73
|
-
# Returns true if the string has UTF-8 semantics (a String used for purely byte resources is unlikely to have
|
|
74
|
-
# them), returns false otherwise.
|
|
75
|
-
def is_utf8?
|
|
76
|
-
Mail::Multibyte::Chars.consumes?(self)
|
|
77
|
-
end
|
|
78
|
-
end
|
|
79
|
-
end
|
|
@@ -1,185 +0,0 @@
|
|
|
1
|
-
%%{
|
|
2
|
-
|
|
3
|
-
machine common;
|
|
4
|
-
|
|
5
|
-
action comment_begin { fcall comment_tail; }
|
|
6
|
-
action comment_exit { fret; }
|
|
7
|
-
|
|
8
|
-
# RFC5322: address_lists, date_time, message_ids, phrase_lists, received
|
|
9
|
-
|
|
10
|
-
obs_NO_WS_CTL = 0x01..0x08 | 0x0b | 0x0c | 0x0e..0x1f | 0x7f;
|
|
11
|
-
LF = "\n";
|
|
12
|
-
CR = "\r";
|
|
13
|
-
CRLF = "\r\n";
|
|
14
|
-
WSP = 0x09 | 0x20;
|
|
15
|
-
obs_ctext = obs_NO_WS_CTL;
|
|
16
|
-
VCHAR = 0x21..0x7e;
|
|
17
|
-
obs_qp = "\\" (0x00 | obs_NO_WS_CTL | LF | CR);
|
|
18
|
-
obs_FWS = (CRLF? WSP)+;
|
|
19
|
-
ctext = 0x21..0x27 | 0x2a..0x5b | 0x5d..0x7e | obs_ctext;
|
|
20
|
-
quoted_pair = ("\\" (VCHAR | WSP)) | obs_qp;
|
|
21
|
-
FWS = (WSP* CRLF WSP+) | (CRLF WSP+) | obs_FWS;
|
|
22
|
-
ALPHA = [a-zA-Z];
|
|
23
|
-
DIGIT = [0-9];
|
|
24
|
-
DQUOTE = '"';
|
|
25
|
-
obs_qtext = obs_NO_WS_CTL;
|
|
26
|
-
atext = ALPHA | DIGIT | "!" | "#" | "$" | "%" | "&" |
|
|
27
|
-
"'" | "*" | "+" | "-" | "/" | "=" | "?" | "^" |
|
|
28
|
-
"_" | "`" | "{" | "|" | "}" | "~";
|
|
29
|
-
qtext = 0x21 | 0x23..0x5b | 0x5d..0x7e | obs_qtext;
|
|
30
|
-
obs_dtext = obs_NO_WS_CTL | quoted_pair;
|
|
31
|
-
qcontent = qtext | quoted_pair;
|
|
32
|
-
|
|
33
|
-
# Handle recursive comments
|
|
34
|
-
ccontent = ctext | quoted_pair | "(" @comment_begin;
|
|
35
|
-
comment_tail := ((FWS? ccontent)* >comment_s) FWS? ")" @comment_exit;
|
|
36
|
-
comment = "(" @comment_begin %comment_e;
|
|
37
|
-
CFWS = ((FWS? comment)+ FWS?) | FWS;
|
|
38
|
-
|
|
39
|
-
quoted_string = CFWS?
|
|
40
|
-
(DQUOTE
|
|
41
|
-
(((FWS? qcontent)* FWS?) >qstr_s %qstr_e)
|
|
42
|
-
DQUOTE)
|
|
43
|
-
CFWS?;
|
|
44
|
-
|
|
45
|
-
atom = CFWS? atext+ CFWS?;
|
|
46
|
-
word = atom | quoted_string;
|
|
47
|
-
|
|
48
|
-
# phrase_lists
|
|
49
|
-
obs_phrase = (word | "." | "@")+;
|
|
50
|
-
phrase = (obs_phrase | word+) >phrase_s %phrase_e;
|
|
51
|
-
phrase_lists = phrase ("," FWS* phrase)*;
|
|
52
|
-
|
|
53
|
-
# address_lists
|
|
54
|
-
|
|
55
|
-
# local_part:
|
|
56
|
-
domain_text = (DQUOTE (FWS? qcontent)+ FWS? DQUOTE) | atext+;
|
|
57
|
-
local_dot_atom_text = ("."* domain_text "."*)+;
|
|
58
|
-
local_dot_atom = CFWS?
|
|
59
|
-
(local_dot_atom_text >local_dot_atom_s %local_dot_atom_pre_comment_e)
|
|
60
|
-
CFWS?;
|
|
61
|
-
obs_local_part = word ("." word)*;
|
|
62
|
-
local_part = (local_dot_atom >local_dot_atom_s %local_dot_atom_e |
|
|
63
|
-
(quoted_string %local_quoted_string_e) |
|
|
64
|
-
obs_local_part);
|
|
65
|
-
|
|
66
|
-
# Treetop parser behavior was to ignore addresses missing '@' inside of angle
|
|
67
|
-
# brackets. This construction preserves that behavior.
|
|
68
|
-
local_part_no_capture = (local_dot_atom | quoted_string | obs_local_part);
|
|
69
|
-
|
|
70
|
-
# domain:
|
|
71
|
-
dot_atom_text = "."* domain_text ("."* domain_text)*;
|
|
72
|
-
dtext = 0x21..0x5a | 0x5e..0x7e | obs_dtext;
|
|
73
|
-
dot_atom = CFWS? dot_atom_text (CFWS? >(comment_after_address,1));
|
|
74
|
-
domain_literal = CFWS? "[" (FWS? dtext)* FWS? "]" CFWS?;
|
|
75
|
-
obs_domain = atom ("." atom)*;
|
|
76
|
-
domain = (dot_atom | domain_literal | obs_domain) >domain_s %domain_e;
|
|
77
|
-
|
|
78
|
-
# addr_spec:
|
|
79
|
-
|
|
80
|
-
# The %(end_addr,N) priority resolves uncertainty when whitespace
|
|
81
|
-
# after an addr_spec could cause it to be interpreted as a
|
|
82
|
-
# display name: "bar@example.com ,..."
|
|
83
|
-
|
|
84
|
-
addr_spec_in_angle_brackets =
|
|
85
|
-
(local_part "@" domain) %(end_addr,1) |
|
|
86
|
-
local_part_no_capture %(end_addr,0);
|
|
87
|
-
|
|
88
|
-
addr_spec_no_angle_brackets =
|
|
89
|
-
(local_part "@" domain) %(end_addr,1) |
|
|
90
|
-
local_part %(end_addr,0);
|
|
91
|
-
|
|
92
|
-
# angle_addr:
|
|
93
|
-
obs_domain_list = (CFWS | ",")* "@" domain ("," CFWS? ("@" domain)?)*;
|
|
94
|
-
obs_route = (obs_domain_list ":") >obs_domain_list_s %obs_domain_list_e;
|
|
95
|
-
obs_angle_addr = CFWS? "<" obs_route? addr_spec_in_angle_brackets ">" CFWS?;
|
|
96
|
-
|
|
97
|
-
angle_addr = CFWS? ("<" >angle_addr_s) addr_spec_in_angle_brackets ">" CFWS? |
|
|
98
|
-
obs_angle_addr;
|
|
99
|
-
|
|
100
|
-
# Address
|
|
101
|
-
display_name = phrase;
|
|
102
|
-
name_addr = display_name? %(end_addr,2) angle_addr;
|
|
103
|
-
mailbox = (name_addr | addr_spec_no_angle_brackets) >address_s %address_e;
|
|
104
|
-
obs_mbox_list = (CFWS? ",")* mailbox ("," (mailbox | CFWS)?)*;
|
|
105
|
-
mailbox_list = (mailbox (("," | ";") mailbox)*) | obs_mbox_list;
|
|
106
|
-
obs_group_list = (CFWS? ",")+ CFWS?;
|
|
107
|
-
group_list = mailbox_list | CFWS | obs_group_list;
|
|
108
|
-
group = (display_name >group_name_s %group_name_e) ":"
|
|
109
|
-
(group_list?) ";" CFWS?;
|
|
110
|
-
address = group | mailbox;
|
|
111
|
-
#obs_addr_list = (CFWS? ",")* address ("," (address | CFWS)?)*;
|
|
112
|
-
address_lists = address? %(comment_after_address,0)
|
|
113
|
-
(FWS* ("," | ";") FWS* address?)*;
|
|
114
|
-
|
|
115
|
-
# message_ids
|
|
116
|
-
obs_id_left = local_part;
|
|
117
|
-
id_left = dot_atom_text | obs_id_left;
|
|
118
|
-
# id_right modifications to support multiple '@' in msg_id.
|
|
119
|
-
msg_id_atext = ALPHA | DIGIT | "!" | "#" | "$" | "%" | "&" | "'" | "*" |
|
|
120
|
-
"+" | "-" | "/" | "=" | "?" | "^" | "_" | "`" | "{" | "|" |
|
|
121
|
-
"}" | "~" | "@";
|
|
122
|
-
msg_id_dot_atom_text = (msg_id_atext+ "."?)+;
|
|
123
|
-
obs_id_right = domain;
|
|
124
|
-
no_fold_literal = "[" (dtext)* "]";
|
|
125
|
-
id_right = msg_id_dot_atom_text | no_fold_literal | obs_id_right;
|
|
126
|
-
msg_id = (CFWS)?
|
|
127
|
-
(("<" id_left "@" id_right ">") >msg_id_s %msg_id_e)
|
|
128
|
-
(CFWS)?;
|
|
129
|
-
message_ids = msg_id (CFWS? msg_id)*;
|
|
130
|
-
|
|
131
|
-
include date_time "date_time.rl";
|
|
132
|
-
date_time = (day_of_week ",")?
|
|
133
|
-
(date >date_s %date_e) <: (time >time_s %time_e) CFWS?;
|
|
134
|
-
|
|
135
|
-
# Added CFWS? to increase robustness
|
|
136
|
-
# (qmail likes to include a comment style string...?)
|
|
137
|
-
received_token = word | angle_addr | addr_spec_no_angle_brackets | domain;
|
|
138
|
-
received = ((CFWS? received_token*) >received_tokens_s %received_tokens_e)
|
|
139
|
-
";" date_time;
|
|
140
|
-
|
|
141
|
-
# RFC2045: mime_version, content_type, content_transfer_encoding
|
|
142
|
-
mime_version = CFWS?
|
|
143
|
-
(DIGIT+ >major_digits_s %major_digits_e)
|
|
144
|
-
comment? "." comment?
|
|
145
|
-
(DIGIT+ >minor_digits_s %minor_digits_e)
|
|
146
|
-
CFWS?;
|
|
147
|
-
|
|
148
|
-
token = 0x21..0x27 | 0x2a..0x2b | 0x2c..0x2e |
|
|
149
|
-
0x30..0x39 | 0x41..0x5a | 0x5e..0x7e;
|
|
150
|
-
value = (quoted_string | (token -- '"' | 0x3d)+) >param_val_s %param_val_e;
|
|
151
|
-
attribute = (token+) >param_attr_s %param_attr_e;
|
|
152
|
-
parameter = CFWS? attribute "=" value CFWS?;
|
|
153
|
-
|
|
154
|
-
ietf_token = token+;
|
|
155
|
-
custom_x_token = 'x'i "-" token+;
|
|
156
|
-
extension_token = ietf_token | custom_x_token;
|
|
157
|
-
discrete_type = 'text'i | 'image'i | 'audio'i | 'video'i |
|
|
158
|
-
'application'i | extension_token;
|
|
159
|
-
composite_type = 'message'i | 'multipart'i | extension_token;
|
|
160
|
-
iana_token = token+;
|
|
161
|
-
main_type = (discrete_type | composite_type) >main_type_s %main_type_e;
|
|
162
|
-
sub_type = (extension_token | iana_token) >sub_type_s %sub_type_e;
|
|
163
|
-
content_type = main_type "/" sub_type (((CFWS? ";"+) | CFWS) parameter CFWS?)*;
|
|
164
|
-
|
|
165
|
-
encoding = ('7bits' | '8bits' | '7bit' | '8bit' | 'binary' |
|
|
166
|
-
'quoted-printable' | 'base64' | ietf_token |
|
|
167
|
-
custom_x_token) >encoding_s %encoding_e;
|
|
168
|
-
content_transfer_encoding = CFWS? encoding CFWS? ";"? CFWS?;
|
|
169
|
-
|
|
170
|
-
# RFC2183: content_disposition
|
|
171
|
-
# TODO: recognize filename, size, creation date, etc.
|
|
172
|
-
disposition_type = 'inline'i | 'attachment'i | extension_token | '';
|
|
173
|
-
content_disposition = (disposition_type >disp_type_s %disp_type_e)
|
|
174
|
-
(CFWS? ";" parameter CFWS?)*;
|
|
175
|
-
|
|
176
|
-
# Envelope From
|
|
177
|
-
ctime_date = day_name " "+ month " "+ day " " time_of_day " " year;
|
|
178
|
-
null_sender = ('<>' ' '{0,1});
|
|
179
|
-
envelope_from = (addr_spec_no_angle_brackets | null_sender) >address_s %address_e " "
|
|
180
|
-
(ctime_date >ctime_date_s %ctime_date_e);
|
|
181
|
-
|
|
182
|
-
# content_location
|
|
183
|
-
location = quoted_string | ((token | 0x3d)+ >token_string_s %token_string_e);
|
|
184
|
-
content_location = CFWS? location CFWS?;
|
|
185
|
-
}%%
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
module Mail
|
|
2
|
-
module Parsers
|
|
3
|
-
module Ragel
|
|
4
|
-
ACTIONS = [
|
|
5
|
-
:addr_spec,
|
|
6
|
-
:address_e,
|
|
7
|
-
:address_s,
|
|
8
|
-
:angle_addr_s,
|
|
9
|
-
:comment_e,
|
|
10
|
-
:comment_s,
|
|
11
|
-
:ctime_date_e,
|
|
12
|
-
:ctime_date_s,
|
|
13
|
-
:date_e,
|
|
14
|
-
:date_s,
|
|
15
|
-
:disp_type_e,
|
|
16
|
-
:disp_type_s,
|
|
17
|
-
:domain_e,
|
|
18
|
-
:domain_s,
|
|
19
|
-
:encoding_e,
|
|
20
|
-
:encoding_s,
|
|
21
|
-
:group_name_e,
|
|
22
|
-
:group_name_s,
|
|
23
|
-
:local_dot_atom_e,
|
|
24
|
-
:local_dot_atom_pre_comment_e,
|
|
25
|
-
:local_dot_atom_s,
|
|
26
|
-
:local_quoted_string_e,
|
|
27
|
-
:main_type_e,
|
|
28
|
-
:main_type_s,
|
|
29
|
-
:major_digits_e,
|
|
30
|
-
:major_digits_s,
|
|
31
|
-
:minor_digits_e,
|
|
32
|
-
:minor_digits_s,
|
|
33
|
-
:msg_id_e,
|
|
34
|
-
:msg_id_s,
|
|
35
|
-
:obs_domain_list_e,
|
|
36
|
-
:obs_domain_list_s,
|
|
37
|
-
:param_attr_e,
|
|
38
|
-
:param_attr_s,
|
|
39
|
-
:param_val_e,
|
|
40
|
-
:param_val_s,
|
|
41
|
-
:phrase_e,
|
|
42
|
-
:phrase_s,
|
|
43
|
-
:qstr_e,
|
|
44
|
-
:qstr_s,
|
|
45
|
-
:received_tokens_e,
|
|
46
|
-
:received_tokens_s,
|
|
47
|
-
:sub_type_e,
|
|
48
|
-
:sub_type_s,
|
|
49
|
-
:time_e,
|
|
50
|
-
:time_s,
|
|
51
|
-
:token_string_e,
|
|
52
|
-
:token_string_s
|
|
53
|
-
]
|
|
54
|
-
|
|
55
|
-
FIELD_PARSERS = %w[ address_lists phrase_lists
|
|
56
|
-
date_time received message_ids envelope_from
|
|
57
|
-
mime_version content_type content_disposition
|
|
58
|
-
content_transfer_encoding content_location ]
|
|
59
|
-
end
|
|
60
|
-
end
|
|
61
|
-
end
|