mail 2.7.1 → 2.8.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +45 -28
- data/lib/mail/attachments_list.rb +2 -5
- data/lib/mail/body.rb +24 -47
- data/lib/mail/constants.rb +27 -5
- data/lib/mail/elements/address.rb +27 -27
- data/lib/mail/elements/address_list.rb +1 -1
- data/lib/mail/elements/content_disposition_element.rb +1 -1
- data/lib/mail/elements/content_location_element.rb +1 -1
- data/lib/mail/elements/content_transfer_encoding_element.rb +1 -1
- data/lib/mail/elements/content_type_element.rb +8 -4
- data/lib/mail/elements/date_time_element.rb +1 -1
- data/lib/mail/elements/envelope_from_element.rb +13 -7
- data/lib/mail/elements/message_ids_element.rb +14 -5
- data/lib/mail/elements/mime_version_element.rb +1 -1
- data/lib/mail/elements/phrase_list.rb +7 -2
- data/lib/mail/elements/received_element.rb +20 -6
- data/lib/mail/encodings/7bit.rb +5 -0
- data/lib/mail/encodings/base64.rb +2 -2
- data/lib/mail/encodings/quoted_printable.rb +2 -2
- data/lib/mail/encodings.rb +30 -59
- data/lib/mail/envelope.rb +11 -14
- data/lib/mail/field.rb +37 -53
- data/lib/mail/field_list.rb +60 -7
- data/lib/mail/fields/bcc_field.rb +34 -52
- data/lib/mail/fields/cc_field.rb +28 -49
- data/lib/mail/fields/comments_field.rb +27 -37
- data/lib/mail/fields/common_address_field.rb +170 -0
- data/lib/mail/fields/common_date_field.rb +58 -0
- data/lib/mail/fields/common_field.rb +77 -0
- data/lib/mail/fields/common_message_id_field.rb +42 -0
- data/lib/mail/fields/content_description_field.rb +7 -14
- data/lib/mail/fields/content_disposition_field.rb +13 -38
- data/lib/mail/fields/content_id_field.rb +24 -51
- data/lib/mail/fields/content_location_field.rb +11 -25
- data/lib/mail/fields/content_transfer_encoding_field.rb +31 -31
- data/lib/mail/fields/content_type_field.rb +46 -71
- data/lib/mail/fields/date_field.rb +23 -51
- data/lib/mail/fields/from_field.rb +28 -49
- data/lib/mail/fields/in_reply_to_field.rb +38 -49
- data/lib/mail/fields/keywords_field.rb +18 -31
- data/lib/mail/fields/message_id_field.rb +25 -71
- data/lib/mail/fields/mime_version_field.rb +19 -30
- data/lib/mail/fields/named_structured_field.rb +11 -0
- data/lib/mail/fields/named_unstructured_field.rb +11 -0
- data/lib/mail/fields/optional_field.rb +5 -6
- data/lib/mail/fields/{common/parameter_hash.rb → parameter_hash.rb} +12 -10
- data/lib/mail/fields/received_field.rb +43 -57
- data/lib/mail/fields/references_field.rb +35 -49
- data/lib/mail/fields/reply_to_field.rb +28 -49
- data/lib/mail/fields/resent_bcc_field.rb +28 -49
- data/lib/mail/fields/resent_cc_field.rb +28 -49
- data/lib/mail/fields/resent_date_field.rb +5 -29
- data/lib/mail/fields/resent_from_field.rb +28 -49
- data/lib/mail/fields/resent_message_id_field.rb +5 -29
- data/lib/mail/fields/resent_sender_field.rb +27 -56
- data/lib/mail/fields/resent_to_field.rb +28 -49
- data/lib/mail/fields/return_path_field.rb +50 -54
- data/lib/mail/fields/sender_field.rb +34 -55
- data/lib/mail/fields/structured_field.rb +3 -30
- data/lib/mail/fields/subject_field.rb +9 -11
- data/lib/mail/fields/to_field.rb +28 -49
- data/lib/mail/fields/unstructured_field.rb +16 -48
- data/lib/mail/header.rb +69 -110
- data/lib/mail/matchers/attachment_matchers.rb +15 -0
- data/lib/mail/message.rb +46 -64
- data/lib/mail/multibyte/chars.rb +8 -166
- data/lib/mail/multibyte/utils.rb +26 -43
- data/lib/mail/multibyte.rb +1 -11
- data/lib/mail/network/delivery_methods/exim.rb +5 -4
- data/lib/mail/network/delivery_methods/file_delivery.rb +11 -10
- data/lib/mail/network/delivery_methods/logger_delivery.rb +2 -5
- data/lib/mail/network/delivery_methods/sendmail.rb +27 -35
- data/lib/mail/network/delivery_methods/smtp.rb +3 -3
- data/lib/mail/network/delivery_methods/smtp_connection.rb +3 -12
- data/lib/mail/network/delivery_methods/test_mailer.rb +4 -2
- data/lib/mail/network/retriever_methods/base.rb +8 -8
- data/lib/mail/network/retriever_methods/imap.rb +2 -2
- data/lib/mail/network/retriever_methods/pop3.rb +2 -2
- data/lib/mail/network/retriever_methods/test_retriever.rb +2 -1
- data/lib/mail/parsers/address_lists_parser.rb +33070 -33064
- data/lib/mail/parsers/address_lists_parser.rl +7 -0
- data/lib/mail/parsers/content_disposition_parser.rb +833 -827
- data/lib/mail/parsers/content_disposition_parser.rl +7 -0
- data/lib/mail/parsers/content_location_parser.rb +770 -764
- data/lib/mail/parsers/content_location_parser.rl +7 -0
- data/lib/mail/parsers/content_transfer_encoding_parser.rb +474 -468
- data/lib/mail/parsers/content_transfer_encoding_parser.rl +7 -0
- data/lib/mail/parsers/content_type_parser.rb +971 -965
- data/lib/mail/parsers/content_type_parser.rl +7 -0
- data/lib/mail/parsers/date_time_parser.rb +838 -832
- data/lib/mail/parsers/date_time_parser.rl +7 -0
- data/lib/mail/parsers/envelope_from_parser.rb +3623 -3529
- data/lib/mail/parsers/envelope_from_parser.rl +7 -0
- data/lib/mail/parsers/message_ids_parser.rb +5107 -2800
- data/lib/mail/parsers/message_ids_parser.rl +12 -1
- data/lib/mail/parsers/mime_version_parser.rb +463 -457
- data/lib/mail/parsers/mime_version_parser.rl +7 -0
- data/lib/mail/parsers/phrase_lists_parser.rb +836 -830
- data/lib/mail/parsers/phrase_lists_parser.rl +8 -1
- data/lib/mail/parsers/received_parser.rb +8688 -8682
- data/lib/mail/parsers/received_parser.rl +7 -0
- data/lib/mail/parsers/rfc5322.rl +28 -13
- data/lib/mail/parsers.rb +11 -17
- data/lib/mail/part.rb +5 -9
- data/lib/mail/parts_list.rb +57 -0
- data/lib/mail/smtp_envelope.rb +57 -0
- data/lib/mail/utilities.rb +307 -69
- data/lib/mail/version.rb +3 -3
- data/lib/mail/yaml.rb +30 -0
- data/lib/mail.rb +0 -20
- metadata +74 -21
- data/lib/mail/check_delivery_params.rb +0 -60
- data/lib/mail/core_extensions/smtp.rb +0 -28
- data/lib/mail/core_extensions/string.rb +0 -17
- data/lib/mail/fields/common/address_container.rb +0 -17
- data/lib/mail/fields/common/common_address.rb +0 -161
- data/lib/mail/fields/common/common_date.rb +0 -36
- data/lib/mail/fields/common/common_field.rb +0 -52
- data/lib/mail/fields/common/common_message_id.rb +0 -49
- data/lib/mail/version_specific/ruby_1_8.rb +0 -163
- data/lib/mail/version_specific/ruby_1_9.rb +0 -278
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mail
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.8.0.rc1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mikel Lindsaar
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-04-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: mini_mime
|
@@ -24,6 +24,48 @@ dependencies:
|
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: 0.1.1
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: net-smtp
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: net-imap
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: net-pop
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
27
69
|
- !ruby/object:Gem::Dependency
|
28
70
|
name: bundler
|
29
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -66,6 +108,20 @@ dependencies:
|
|
66
108
|
- - "~>"
|
67
109
|
- !ruby/object:Gem::Version
|
68
110
|
version: '3.0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: rspec-benchmark
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
69
125
|
- !ruby/object:Gem::Dependency
|
70
126
|
name: rdoc
|
71
127
|
requirement: !ruby/object:Gem::Requirement
|
@@ -106,11 +162,8 @@ files:
|
|
106
162
|
- lib/mail.rb
|
107
163
|
- lib/mail/attachments_list.rb
|
108
164
|
- lib/mail/body.rb
|
109
|
-
- lib/mail/check_delivery_params.rb
|
110
165
|
- lib/mail/configuration.rb
|
111
166
|
- lib/mail/constants.rb
|
112
|
-
- lib/mail/core_extensions/smtp.rb
|
113
|
-
- lib/mail/core_extensions/string.rb
|
114
167
|
- lib/mail/elements.rb
|
115
168
|
- lib/mail/elements/address.rb
|
116
169
|
- lib/mail/elements/address_list.rb
|
@@ -140,12 +193,10 @@ files:
|
|
140
193
|
- lib/mail/fields/bcc_field.rb
|
141
194
|
- lib/mail/fields/cc_field.rb
|
142
195
|
- lib/mail/fields/comments_field.rb
|
143
|
-
- lib/mail/fields/
|
144
|
-
- lib/mail/fields/
|
145
|
-
- lib/mail/fields/
|
146
|
-
- lib/mail/fields/
|
147
|
-
- lib/mail/fields/common/common_message_id.rb
|
148
|
-
- lib/mail/fields/common/parameter_hash.rb
|
196
|
+
- lib/mail/fields/common_address_field.rb
|
197
|
+
- lib/mail/fields/common_date_field.rb
|
198
|
+
- lib/mail/fields/common_field.rb
|
199
|
+
- lib/mail/fields/common_message_id_field.rb
|
149
200
|
- lib/mail/fields/content_description_field.rb
|
150
201
|
- lib/mail/fields/content_disposition_field.rb
|
151
202
|
- lib/mail/fields/content_id_field.rb
|
@@ -158,7 +209,10 @@ files:
|
|
158
209
|
- lib/mail/fields/keywords_field.rb
|
159
210
|
- lib/mail/fields/message_id_field.rb
|
160
211
|
- lib/mail/fields/mime_version_field.rb
|
212
|
+
- lib/mail/fields/named_structured_field.rb
|
213
|
+
- lib/mail/fields/named_unstructured_field.rb
|
161
214
|
- lib/mail/fields/optional_field.rb
|
215
|
+
- lib/mail/fields/parameter_hash.rb
|
162
216
|
- lib/mail/fields/received_field.rb
|
163
217
|
- lib/mail/fields/references_field.rb
|
164
218
|
- lib/mail/fields/reply_to_field.rb
|
@@ -233,16 +287,16 @@ files:
|
|
233
287
|
- lib/mail/parsers/rfc5322_lexical_tokens.rl
|
234
288
|
- lib/mail/part.rb
|
235
289
|
- lib/mail/parts_list.rb
|
290
|
+
- lib/mail/smtp_envelope.rb
|
236
291
|
- lib/mail/utilities.rb
|
237
292
|
- lib/mail/values/unicode_tables.dat
|
238
293
|
- lib/mail/version.rb
|
239
|
-
- lib/mail/
|
240
|
-
- lib/mail/version_specific/ruby_1_9.rb
|
294
|
+
- lib/mail/yaml.rb
|
241
295
|
homepage: https://github.com/mikel/mail
|
242
296
|
licenses:
|
243
297
|
- MIT
|
244
298
|
metadata: {}
|
245
|
-
post_install_message:
|
299
|
+
post_install_message:
|
246
300
|
rdoc_options:
|
247
301
|
- "--exclude"
|
248
302
|
- lib/mail/values/unicode_tables.dat
|
@@ -252,16 +306,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
252
306
|
requirements:
|
253
307
|
- - ">="
|
254
308
|
- !ruby/object:Gem::Version
|
255
|
-
version: '
|
309
|
+
version: '2.5'
|
256
310
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
257
311
|
requirements:
|
258
|
-
- - "
|
312
|
+
- - ">"
|
259
313
|
- !ruby/object:Gem::Version
|
260
|
-
version:
|
314
|
+
version: 1.3.1
|
261
315
|
requirements: []
|
262
|
-
|
263
|
-
|
264
|
-
signing_key:
|
316
|
+
rubygems_version: 3.0.8
|
317
|
+
signing_key:
|
265
318
|
specification_version: 4
|
266
319
|
summary: Mail provides a nice Ruby DSL for making, sending and reading emails.
|
267
320
|
test_files: []
|
@@ -1,60 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
module Mail
|
3
|
-
module CheckDeliveryParams #:nodoc:
|
4
|
-
class << self
|
5
|
-
def check(mail)
|
6
|
-
[ check_from(mail.smtp_envelope_from),
|
7
|
-
check_to(mail.smtp_envelope_to),
|
8
|
-
check_message(mail) ]
|
9
|
-
end
|
10
|
-
|
11
|
-
def check_from(addr)
|
12
|
-
if Utilities.blank?(addr)
|
13
|
-
raise ArgumentError, "SMTP From address may not be blank: #{addr.inspect}"
|
14
|
-
end
|
15
|
-
|
16
|
-
check_addr 'From', addr
|
17
|
-
end
|
18
|
-
|
19
|
-
def check_to(addrs)
|
20
|
-
if Utilities.blank?(addrs)
|
21
|
-
raise ArgumentError, "SMTP To address may not be blank: #{addrs.inspect}"
|
22
|
-
end
|
23
|
-
|
24
|
-
Array(addrs).map do |addr|
|
25
|
-
check_addr 'To', addr
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
def check_addr(addr_name, addr)
|
30
|
-
validate_smtp_addr addr do |error_message|
|
31
|
-
raise ArgumentError, "SMTP #{addr_name} address #{error_message}: #{addr.inspect}"
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
def validate_smtp_addr(addr)
|
36
|
-
if addr
|
37
|
-
if addr.bytesize > 2048
|
38
|
-
yield 'may not exceed 2kB'
|
39
|
-
end
|
40
|
-
|
41
|
-
if /[\r\n]/ =~ addr
|
42
|
-
yield 'may not contain CR or LF line breaks'
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
addr
|
47
|
-
end
|
48
|
-
|
49
|
-
def check_message(message)
|
50
|
-
message = message.encoded if message.respond_to?(:encoded)
|
51
|
-
|
52
|
-
if Utilities.blank?(message)
|
53
|
-
raise ArgumentError, 'An encoded message is required to send an email'
|
54
|
-
end
|
55
|
-
|
56
|
-
message
|
57
|
-
end
|
58
|
-
end
|
59
|
-
end
|
60
|
-
end
|
@@ -1,28 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
# frozen_string_literal: true
|
3
|
-
|
4
|
-
# This is a backport of r30294 from ruby trunk because of a bug in net/smtp.
|
5
|
-
# http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=30294
|
6
|
-
#
|
7
|
-
# Fixed in Ruby 1.9.3 - tlsconnect also does not exist in some early versions of ruby
|
8
|
-
if RUBY_VERSION < '1.9.3'
|
9
|
-
module Net
|
10
|
-
class SMTP
|
11
|
-
begin
|
12
|
-
alias_method :original_tlsconnect, :tlsconnect
|
13
|
-
|
14
|
-
def tlsconnect(s)
|
15
|
-
verified = false
|
16
|
-
begin
|
17
|
-
original_tlsconnect(s).tap { verified = true }
|
18
|
-
ensure
|
19
|
-
unless verified
|
20
|
-
s.close rescue nil
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
24
|
-
rescue NameError
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
@@ -1,17 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
# frozen_string_literal: true
|
3
|
-
class String #:nodoc:
|
4
|
-
|
5
|
-
unless method_defined?(:ascii_only?)
|
6
|
-
# Backport from Ruby 1.9 checks for non-us-ascii characters.
|
7
|
-
def ascii_only?
|
8
|
-
self !~ MATCH_NON_US_ASCII
|
9
|
-
end
|
10
|
-
|
11
|
-
MATCH_NON_US_ASCII = /[^\x00-\x7f]/
|
12
|
-
end
|
13
|
-
|
14
|
-
unless method_defined?(:bytesize)
|
15
|
-
alias :bytesize :length
|
16
|
-
end
|
17
|
-
end
|
@@ -1,161 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
# frozen_string_literal: true
|
3
|
-
require 'mail/fields/common/address_container'
|
4
|
-
|
5
|
-
module Mail
|
6
|
-
module CommonAddress # :nodoc:
|
7
|
-
def parse(val = value)
|
8
|
-
unless Utilities.blank?(val)
|
9
|
-
@address_list = AddressList.new(encode_if_needed(val))
|
10
|
-
else
|
11
|
-
nil
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
def charset
|
16
|
-
@charset
|
17
|
-
end
|
18
|
-
|
19
|
-
def encode_if_needed(val) #:nodoc:
|
20
|
-
# Need to join arrays of addresses into a single value
|
21
|
-
if val.kind_of?(Array)
|
22
|
-
val.compact.map { |a| encode_if_needed a }.join(', ')
|
23
|
-
|
24
|
-
# Pass through UTF-8; encode non-UTF-8.
|
25
|
-
else
|
26
|
-
utf8_if_needed(val) || Encodings.encode_non_usascii(val, charset)
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
# Allows you to iterate through each address object in the address_list
|
31
|
-
def each
|
32
|
-
address_list.addresses.each do |address|
|
33
|
-
yield(address)
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
# Returns the address string of all the addresses in the address list
|
38
|
-
def addresses
|
39
|
-
list = address_list.addresses.map { |a| a.address }
|
40
|
-
Mail::AddressContainer.new(self, list)
|
41
|
-
end
|
42
|
-
|
43
|
-
# Returns the formatted string of all the addresses in the address list
|
44
|
-
def formatted
|
45
|
-
list = address_list.addresses.map { |a| a.format }
|
46
|
-
Mail::AddressContainer.new(self, list)
|
47
|
-
end
|
48
|
-
|
49
|
-
# Returns the display name of all the addresses in the address list
|
50
|
-
def display_names
|
51
|
-
list = address_list.addresses.map { |a| a.display_name }
|
52
|
-
Mail::AddressContainer.new(self, list)
|
53
|
-
end
|
54
|
-
|
55
|
-
# Returns the actual address objects in the address list
|
56
|
-
def addrs
|
57
|
-
list = address_list.addresses
|
58
|
-
Mail::AddressContainer.new(self, list)
|
59
|
-
end
|
60
|
-
|
61
|
-
# Returns a hash of group name => address strings for the address list
|
62
|
-
def groups
|
63
|
-
address_list.addresses_grouped_by_group
|
64
|
-
end
|
65
|
-
|
66
|
-
# Returns the addresses that are part of groups
|
67
|
-
def group_addresses
|
68
|
-
decoded_group_addresses
|
69
|
-
end
|
70
|
-
|
71
|
-
# Returns a list of decoded group addresses
|
72
|
-
def decoded_group_addresses
|
73
|
-
groups.map { |k,v| v.map { |a| a.decoded } }.flatten
|
74
|
-
end
|
75
|
-
|
76
|
-
# Returns a list of encoded group addresses
|
77
|
-
def encoded_group_addresses
|
78
|
-
groups.map { |k,v| v.map { |a| a.encoded } }.flatten
|
79
|
-
end
|
80
|
-
|
81
|
-
# Returns the name of all the groups in a string
|
82
|
-
def group_names # :nodoc:
|
83
|
-
address_list.group_names
|
84
|
-
end
|
85
|
-
|
86
|
-
def default
|
87
|
-
addresses
|
88
|
-
end
|
89
|
-
|
90
|
-
def <<(val)
|
91
|
-
case
|
92
|
-
when val.nil?
|
93
|
-
raise ArgumentError, "Need to pass an address to <<"
|
94
|
-
when Utilities.blank?(val)
|
95
|
-
parse(encoded)
|
96
|
-
else
|
97
|
-
self.value = [self.value, val].reject {|a| Utilities.blank?(a) }.join(", ")
|
98
|
-
end
|
99
|
-
end
|
100
|
-
|
101
|
-
def value=(val)
|
102
|
-
super
|
103
|
-
parse(self.value)
|
104
|
-
end
|
105
|
-
|
106
|
-
private
|
107
|
-
|
108
|
-
if 'string'.respond_to?(:encoding)
|
109
|
-
# Pass through UTF-8 addresses
|
110
|
-
def utf8_if_needed(val)
|
111
|
-
if charset =~ /\AUTF-?8\z/i
|
112
|
-
val
|
113
|
-
elsif val.encoding == Encoding::UTF_8
|
114
|
-
val
|
115
|
-
elsif (utf8 = val.dup.force_encoding(Encoding::UTF_8)).valid_encoding?
|
116
|
-
utf8
|
117
|
-
end
|
118
|
-
end
|
119
|
-
else
|
120
|
-
def utf8_if_needed(val)
|
121
|
-
if charset =~ /\AUTF-?8\z/i
|
122
|
-
val
|
123
|
-
end
|
124
|
-
end
|
125
|
-
end
|
126
|
-
|
127
|
-
def do_encode(field_name)
|
128
|
-
return '' if Utilities.blank?(value)
|
129
|
-
address_array = address_list.addresses.reject { |a| encoded_group_addresses.include?(a.encoded) }.compact.map { |a| a.encoded }
|
130
|
-
address_text = address_array.join(", \r\n\s")
|
131
|
-
group_array = groups.map { |k,v| "#{k}: #{v.map { |a| a.encoded }.join(", \r\n\s")};" }
|
132
|
-
group_text = group_array.join(" \r\n\s")
|
133
|
-
return_array = [address_text, group_text].reject { |a| Utilities.blank?(a) }
|
134
|
-
"#{field_name}: #{return_array.join(", \r\n\s")}\r\n"
|
135
|
-
end
|
136
|
-
|
137
|
-
def do_decode
|
138
|
-
return nil if Utilities.blank?(value)
|
139
|
-
address_array = address_list.addresses.reject { |a| decoded_group_addresses.include?(a.decoded) }.map { |a| a.decoded }
|
140
|
-
address_text = address_array.join(", ")
|
141
|
-
group_array = groups.map { |k,v| "#{k}: #{v.map { |a| a.decoded }.join(", ")};" }
|
142
|
-
group_text = group_array.join(" ")
|
143
|
-
return_array = [address_text, group_text].reject { |a| Utilities.blank?(a) }
|
144
|
-
return_array.join(", ")
|
145
|
-
end
|
146
|
-
|
147
|
-
def address_list # :nodoc:
|
148
|
-
@address_list ||= AddressList.new(value)
|
149
|
-
end
|
150
|
-
|
151
|
-
def get_group_addresses(group_list)
|
152
|
-
if group_list.respond_to?(:addresses)
|
153
|
-
group_list.addresses.map do |address|
|
154
|
-
Mail::Address.new(address)
|
155
|
-
end
|
156
|
-
else
|
157
|
-
[]
|
158
|
-
end
|
159
|
-
end
|
160
|
-
end
|
161
|
-
end
|
@@ -1,36 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
# frozen_string_literal: true
|
3
|
-
module Mail
|
4
|
-
module CommonDate # :nodoc:
|
5
|
-
# Returns a date time object of the parsed date
|
6
|
-
def date_time
|
7
|
-
::DateTime.parse("#{element.date_string} #{element.time_string}")
|
8
|
-
end
|
9
|
-
|
10
|
-
def default
|
11
|
-
date_time
|
12
|
-
end
|
13
|
-
|
14
|
-
def parse(val = value)
|
15
|
-
unless Utilities.blank?(val)
|
16
|
-
@element = Mail::DateTimeElement.new(val)
|
17
|
-
else
|
18
|
-
nil
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
private
|
23
|
-
|
24
|
-
def do_encode(field_name)
|
25
|
-
"#{field_name}: #{value}\r\n"
|
26
|
-
end
|
27
|
-
|
28
|
-
def do_decode
|
29
|
-
"#{value}"
|
30
|
-
end
|
31
|
-
|
32
|
-
def element
|
33
|
-
@element ||= Mail::DateTimeElement.new(value)
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
@@ -1,52 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
# frozen_string_literal: true
|
3
|
-
module Mail
|
4
|
-
module CommonField # :nodoc:
|
5
|
-
include Mail::Constants
|
6
|
-
|
7
|
-
def name=(value)
|
8
|
-
@name = value
|
9
|
-
end
|
10
|
-
|
11
|
-
def name
|
12
|
-
@name ||= nil
|
13
|
-
end
|
14
|
-
|
15
|
-
def value=(value)
|
16
|
-
@length = nil
|
17
|
-
@element = nil
|
18
|
-
@value = value.is_a?(Array) ? value : value.to_s
|
19
|
-
end
|
20
|
-
|
21
|
-
def value
|
22
|
-
@value
|
23
|
-
end
|
24
|
-
|
25
|
-
def to_s
|
26
|
-
decoded.to_s
|
27
|
-
end
|
28
|
-
|
29
|
-
def default
|
30
|
-
decoded
|
31
|
-
end
|
32
|
-
|
33
|
-
def field_length
|
34
|
-
@length ||= "#{name}: #{encode(decoded)}".length
|
35
|
-
end
|
36
|
-
|
37
|
-
def responsible_for?( val )
|
38
|
-
name.to_s.casecmp(val.to_s) == 0
|
39
|
-
end
|
40
|
-
|
41
|
-
private
|
42
|
-
|
43
|
-
FILENAME_RE = /\b(filename|name)=([^;"\r\n]+\s[^;"\r\n]+)/
|
44
|
-
def ensure_filename_quoted(value)
|
45
|
-
if value.is_a?(String)
|
46
|
-
value.sub FILENAME_RE, '\1="\2"'
|
47
|
-
else
|
48
|
-
value
|
49
|
-
end
|
50
|
-
end
|
51
|
-
end
|
52
|
-
end
|
@@ -1,49 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
# frozen_string_literal: true
|
3
|
-
module Mail
|
4
|
-
module CommonMessageId # :nodoc:
|
5
|
-
def element
|
6
|
-
@element ||= Mail::MessageIdsElement.new(value) unless Utilities.blank?(value)
|
7
|
-
end
|
8
|
-
|
9
|
-
def parse(val = value)
|
10
|
-
unless Utilities.blank?(val)
|
11
|
-
@element = Mail::MessageIdsElement.new(val)
|
12
|
-
else
|
13
|
-
nil
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
def message_id
|
18
|
-
element.message_id if element
|
19
|
-
end
|
20
|
-
|
21
|
-
def message_ids
|
22
|
-
element.message_ids if element
|
23
|
-
end
|
24
|
-
|
25
|
-
def default
|
26
|
-
return nil unless message_ids
|
27
|
-
if message_ids.length == 1
|
28
|
-
message_ids[0]
|
29
|
-
else
|
30
|
-
message_ids
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
private
|
35
|
-
|
36
|
-
def do_encode(field_name)
|
37
|
-
%Q{#{field_name}: #{formated_message_ids("\r\n ")}\r\n}
|
38
|
-
end
|
39
|
-
|
40
|
-
def do_decode
|
41
|
-
formated_message_ids(' ')
|
42
|
-
end
|
43
|
-
|
44
|
-
def formated_message_ids(join)
|
45
|
-
message_ids.map{ |m| "<#{m}>" }.join(join) if message_ids
|
46
|
-
end
|
47
|
-
|
48
|
-
end
|
49
|
-
end
|