mail 2.7.1 → 2.8.0
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/check_delivery_params.rb +21 -16
- 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 +52 -66
- 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 +25 -9
- 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 +2 -2
- data/lib/mail/yaml.rb +30 -0
- data/lib/mail.rb +3 -20
- metadata +72 -18
- 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
@@ -1,25 +1,18 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
# frozen_string_literal: true
|
3
|
-
require 'mail/fields/
|
3
|
+
require 'mail/fields/named_structured_field'
|
4
|
+
require 'mail/fields/parameter_hash'
|
4
5
|
|
5
6
|
module Mail
|
6
|
-
class ContentDispositionField <
|
7
|
+
class ContentDispositionField < NamedStructuredField #:nodoc:
|
8
|
+
NAME = 'Content-Disposition'
|
7
9
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
def initialize(value = nil, charset = 'utf-8')
|
12
|
-
self.charset = charset
|
13
|
-
value = ensure_filename_quoted(value)
|
14
|
-
super(CAPITALIZED_FIELD, value, charset)
|
15
|
-
self.parse
|
16
|
-
self
|
10
|
+
def self.singular?
|
11
|
+
true
|
17
12
|
end
|
18
13
|
|
19
|
-
def
|
20
|
-
|
21
|
-
@element = Mail::ContentDispositionElement.new(val)
|
22
|
-
end
|
14
|
+
def initialize(value = nil, charset = nil)
|
15
|
+
super ensure_filename_quoted(value), charset
|
23
16
|
end
|
24
17
|
|
25
18
|
def element
|
@@ -37,35 +30,17 @@ module Mail
|
|
37
30
|
end
|
38
31
|
|
39
32
|
def filename
|
40
|
-
|
41
|
-
when parameters['filename']
|
42
|
-
@filename = parameters['filename']
|
43
|
-
when parameters['name']
|
44
|
-
@filename = parameters['name']
|
45
|
-
else
|
46
|
-
@filename = nil
|
47
|
-
end
|
48
|
-
@filename
|
33
|
+
@filename ||= parameters['filename'] || parameters['name']
|
49
34
|
end
|
50
35
|
|
51
|
-
# TODO: Fix this up
|
52
36
|
def encoded
|
53
|
-
if parameters.length > 0
|
54
|
-
|
55
|
-
else
|
56
|
-
p = "\r\n"
|
57
|
-
end
|
58
|
-
"#{CAPITALIZED_FIELD}: #{disposition_type}" + p
|
37
|
+
p = ";\r\n\s#{parameters.encoded}" if parameters.length > 0
|
38
|
+
"#{name}: #{disposition_type}#{p}\r\n"
|
59
39
|
end
|
60
40
|
|
61
41
|
def decoded
|
62
|
-
if parameters.length > 0
|
63
|
-
|
64
|
-
else
|
65
|
-
p = ""
|
66
|
-
end
|
67
|
-
"#{disposition_type}" + p
|
42
|
+
p = "; #{parameters.decoded}" if parameters.length > 0
|
43
|
+
"#{disposition_type}#{p}"
|
68
44
|
end
|
69
|
-
|
70
45
|
end
|
71
46
|
end
|
@@ -1,63 +1,36 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
# frozen_string_literal: true
|
3
|
-
|
4
|
-
|
5
|
-
|
3
|
+
require 'mail/fields/named_structured_field'
|
4
|
+
require 'mail/utilities'
|
5
|
+
|
6
6
|
module Mail
|
7
|
-
class ContentIdField <
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
if Utilities.blank?(value)
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
end
|
20
|
-
super(CAPITALIZED_FIELD, value, charset)
|
21
|
-
self.parse
|
22
|
-
self
|
23
|
-
end
|
24
|
-
|
25
|
-
def parse(val = value)
|
26
|
-
unless Utilities.blank?(val)
|
27
|
-
@element = Mail::MessageIdsElement.new(val)
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
7
|
+
class ContentIdField < NamedStructuredField #:nodoc:
|
8
|
+
NAME = 'Content-ID'
|
9
|
+
|
10
|
+
def self.singular?
|
11
|
+
true
|
12
|
+
end
|
13
|
+
|
14
|
+
def initialize(value = nil, charset = nil)
|
15
|
+
value = Mail::Utilities.generate_message_id if Utilities.blank?(value)
|
16
|
+
super value, charset
|
17
|
+
end
|
18
|
+
|
31
19
|
def element
|
32
20
|
@element ||= Mail::MessageIdsElement.new(value)
|
33
21
|
end
|
34
|
-
|
35
|
-
def name
|
36
|
-
'Content-ID'
|
37
|
-
end
|
38
|
-
|
22
|
+
|
39
23
|
def content_id
|
40
24
|
element.message_id
|
41
25
|
end
|
42
|
-
|
43
|
-
def to_s
|
44
|
-
"<#{content_id}>"
|
45
|
-
end
|
46
|
-
|
47
|
-
# TODO: Fix this up
|
48
|
-
def encoded
|
49
|
-
"#{CAPITALIZED_FIELD}: #{to_s}\r\n"
|
50
|
-
end
|
51
|
-
|
52
|
-
def decoded
|
53
|
-
"#{to_s}"
|
54
|
-
end
|
55
|
-
|
26
|
+
|
56
27
|
private
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
28
|
+
def do_decode
|
29
|
+
"<#{content_id}>"
|
30
|
+
end
|
31
|
+
|
32
|
+
def do_encode
|
33
|
+
"#{name}: #{do_decode}\r\n"
|
34
|
+
end
|
62
35
|
end
|
63
36
|
end
|
@@ -1,27 +1,15 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
# frozen_string_literal: true
|
3
|
-
|
4
|
-
|
5
|
-
#
|
3
|
+
require 'mail/fields/named_structured_field'
|
4
|
+
|
6
5
|
module Mail
|
7
|
-
class ContentLocationField <
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
def initialize(value = nil, charset = 'utf-8')
|
13
|
-
self.charset = charset
|
14
|
-
super(CAPITALIZED_FIELD, value, charset)
|
15
|
-
self.parse
|
16
|
-
self
|
17
|
-
end
|
18
|
-
|
19
|
-
def parse(val = value)
|
20
|
-
unless Utilities.blank?(val)
|
21
|
-
@element = Mail::ContentLocationElement.new(val)
|
22
|
-
end
|
6
|
+
class ContentLocationField < NamedStructuredField #:nodoc:
|
7
|
+
NAME = 'Content-Location'
|
8
|
+
|
9
|
+
def self.singular?
|
10
|
+
true
|
23
11
|
end
|
24
|
-
|
12
|
+
|
25
13
|
def element
|
26
14
|
@element ||= Mail::ContentLocationElement.new(value)
|
27
15
|
end
|
@@ -30,14 +18,12 @@ module Mail
|
|
30
18
|
element.location
|
31
19
|
end
|
32
20
|
|
33
|
-
# TODO: Fix this up
|
34
21
|
def encoded
|
35
|
-
"#{
|
22
|
+
"#{name}: #{location}\r\n"
|
36
23
|
end
|
37
|
-
|
24
|
+
|
38
25
|
def decoded
|
39
|
-
location
|
26
|
+
location
|
40
27
|
end
|
41
|
-
|
42
28
|
end
|
43
29
|
end
|
@@ -1,45 +1,45 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
# frozen_string_literal: true
|
3
|
-
|
4
|
-
|
5
|
-
#
|
3
|
+
require 'mail/fields/named_structured_field'
|
4
|
+
|
6
5
|
module Mail
|
7
|
-
class ContentTransferEncodingField <
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
def initialize(value = nil, charset = 'utf-8')
|
13
|
-
self.charset = charset
|
14
|
-
value = '7bit' if value.to_s =~ /7-?bits?/i
|
15
|
-
value = '8bit' if value.to_s =~ /8-?bits?/i
|
16
|
-
super(CAPITALIZED_FIELD, value, charset)
|
17
|
-
self.parse
|
18
|
-
self
|
6
|
+
class ContentTransferEncodingField < NamedStructuredField #:nodoc:
|
7
|
+
NAME = 'Content-Transfer-Encoding'
|
8
|
+
|
9
|
+
def self.singular?
|
10
|
+
true
|
19
11
|
end
|
20
|
-
|
21
|
-
def
|
22
|
-
|
23
|
-
|
12
|
+
|
13
|
+
def self.normalize_content_transfer_encoding(value)
|
14
|
+
case value
|
15
|
+
when /7-?bits?/i
|
16
|
+
'7bit'
|
17
|
+
when /8-?bits?/i
|
18
|
+
'8bit'
|
19
|
+
else
|
20
|
+
value
|
24
21
|
end
|
25
22
|
end
|
26
|
-
|
23
|
+
|
24
|
+
def initialize(value = nil, charset = nil)
|
25
|
+
super self.class.normalize_content_transfer_encoding(value), charset
|
26
|
+
end
|
27
|
+
|
27
28
|
def element
|
28
29
|
@element ||= Mail::ContentTransferEncodingElement.new(value)
|
29
30
|
end
|
30
|
-
|
31
|
+
|
31
32
|
def encoding
|
32
33
|
element.encoding
|
33
34
|
end
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
35
|
+
|
36
|
+
private
|
37
|
+
def do_encode
|
38
|
+
"#{name}: #{encoding}\r\n"
|
39
|
+
end
|
40
|
+
|
41
|
+
def do_decode
|
42
|
+
encoding
|
43
|
+
end
|
44
44
|
end
|
45
45
|
end
|
@@ -1,53 +1,55 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
# frozen_string_literal: true
|
3
|
-
require 'mail/fields/
|
3
|
+
require 'mail/fields/named_structured_field'
|
4
|
+
require 'mail/fields/parameter_hash'
|
4
5
|
|
5
6
|
module Mail
|
6
|
-
class ContentTypeField <
|
7
|
+
class ContentTypeField < NamedStructuredField #:nodoc:
|
8
|
+
NAME = 'Content-Type'
|
7
9
|
|
8
|
-
|
9
|
-
|
10
|
+
class << self
|
11
|
+
def singular?
|
12
|
+
true
|
13
|
+
end
|
14
|
+
|
15
|
+
def with_boundary(type)
|
16
|
+
new "#{type}; boundary=#{generate_boundary}"
|
17
|
+
end
|
18
|
+
|
19
|
+
def generate_boundary
|
20
|
+
"--==_mimepart_#{Mail.random_tag}"
|
21
|
+
end
|
22
|
+
end
|
10
23
|
|
11
|
-
def initialize(value = nil, charset =
|
12
|
-
|
13
|
-
if value.class == Array
|
24
|
+
def initialize(value = nil, charset = nil)
|
25
|
+
if value.is_a? Array
|
14
26
|
@main_type = value[0]
|
15
27
|
@sub_type = value[1]
|
16
28
|
@parameters = ParameterHash.new.merge!(value.last)
|
17
29
|
else
|
18
30
|
@main_type = nil
|
19
31
|
@sub_type = nil
|
20
|
-
@parameters = nil
|
21
32
|
value = value.to_s
|
22
33
|
end
|
23
|
-
value = ensure_filename_quoted(value)
|
24
|
-
super(CAPITALIZED_FIELD, value, charset)
|
25
|
-
self.parse
|
26
|
-
self
|
27
|
-
end
|
28
34
|
|
29
|
-
|
30
|
-
unless Utilities.blank?(val)
|
31
|
-
self.value = val
|
32
|
-
@element = nil
|
33
|
-
element
|
34
|
-
end
|
35
|
+
super ensure_filename_quoted(value), charset
|
35
36
|
end
|
36
37
|
|
37
38
|
def element
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
39
|
+
@element ||=
|
40
|
+
begin
|
41
|
+
Mail::ContentTypeElement.new(value)
|
42
|
+
rescue Mail::Field::ParseError
|
43
|
+
attempt_to_clean
|
44
|
+
end
|
43
45
|
end
|
44
46
|
|
45
47
|
def attempt_to_clean
|
46
48
|
# Sanitize the value, handle special cases
|
47
|
-
|
48
|
-
rescue
|
49
|
+
Mail::ContentTypeElement.new(sanitize(value))
|
50
|
+
rescue Mail::Field::ParseError
|
49
51
|
# All else fails, just get the MIME media type
|
50
|
-
|
52
|
+
Mail::ContentTypeElement.new(get_mime_type(value))
|
51
53
|
end
|
52
54
|
|
53
55
|
def main_type
|
@@ -61,31 +63,22 @@ module Mail
|
|
61
63
|
def string
|
62
64
|
"#{main_type}/#{sub_type}"
|
63
65
|
end
|
66
|
+
alias_method :content_type, :string
|
64
67
|
|
65
68
|
def default
|
66
69
|
decoded
|
67
70
|
end
|
68
71
|
|
69
|
-
alias :content_type :string
|
70
|
-
|
71
72
|
def parameters
|
72
|
-
unless @parameters
|
73
|
+
unless defined? @parameters
|
73
74
|
@parameters = ParameterHash.new
|
74
75
|
element.parameters.each { |p| @parameters.merge!(p) }
|
75
76
|
end
|
76
77
|
@parameters
|
77
78
|
end
|
78
79
|
|
79
|
-
def ContentTypeField.with_boundary(type)
|
80
|
-
new("#{type}; boundary=#{generate_boundary}")
|
81
|
-
end
|
82
|
-
|
83
|
-
def ContentTypeField.generate_boundary
|
84
|
-
"--==_mimepart_#{Mail.random_tag}"
|
85
|
-
end
|
86
|
-
|
87
80
|
def value
|
88
|
-
if @value.
|
81
|
+
if @value.is_a? Array
|
89
82
|
"#{@main_type}/#{@sub_type}; #{stringify(parameters)}"
|
90
83
|
else
|
91
84
|
@value
|
@@ -97,34 +90,17 @@ module Mail
|
|
97
90
|
end
|
98
91
|
|
99
92
|
def filename
|
100
|
-
|
101
|
-
when parameters['filename']
|
102
|
-
@filename = parameters['filename']
|
103
|
-
when parameters['name']
|
104
|
-
@filename = parameters['name']
|
105
|
-
else
|
106
|
-
@filename = nil
|
107
|
-
end
|
108
|
-
@filename
|
93
|
+
@filename ||= parameters['filename'] || parameters['name']
|
109
94
|
end
|
110
95
|
|
111
|
-
# TODO: Fix this up
|
112
96
|
def encoded
|
113
|
-
if parameters.length > 0
|
114
|
-
|
115
|
-
else
|
116
|
-
p = ""
|
117
|
-
end
|
118
|
-
"#{CAPITALIZED_FIELD}: #{content_type}#{p}\r\n"
|
97
|
+
p = ";\r\n\s#{parameters.encoded}" if parameters && parameters.length > 0
|
98
|
+
"#{name}: #{content_type}#{p}\r\n"
|
119
99
|
end
|
120
100
|
|
121
101
|
def decoded
|
122
|
-
if parameters.length > 0
|
123
|
-
|
124
|
-
else
|
125
|
-
p = ""
|
126
|
-
end
|
127
|
-
"#{content_type}" + p
|
102
|
+
p = "; #{parameters.decoded}" if parameters && parameters.length > 0
|
103
|
+
"#{content_type}#{p}"
|
128
104
|
end
|
129
105
|
|
130
106
|
private
|
@@ -140,16 +116,15 @@ module Mail
|
|
140
116
|
|
141
117
|
# Various special cases from random emails found that I am not going to change
|
142
118
|
# the parser for
|
143
|
-
def
|
144
|
-
|
119
|
+
def sanitize(val)
|
145
120
|
# TODO: check if there are cases where whitespace is not a separator
|
146
121
|
val = val.
|
147
122
|
gsub(/\s*=\s*/,'='). # remove whitespaces around equal sign
|
148
123
|
gsub(/[; ]+/, '; '). #use '; ' as a separator (or EOL)
|
149
124
|
gsub(/;\s*$/,'') #remove trailing to keep examples below
|
150
125
|
|
151
|
-
if val =~ /(boundary=(\S*))/i
|
152
|
-
val = "#{$`.downcase}
|
126
|
+
if val =~ /((boundary|name|filename)=(\S*))/i
|
127
|
+
val = "#{$`.downcase}#{$2}=#{$3}#{$'.downcase}"
|
153
128
|
else
|
154
129
|
val.downcase!
|
155
130
|
end
|
@@ -158,7 +133,7 @@ module Mail
|
|
158
133
|
when val.chomp =~ /^\s*([\w\-]+)\/([\w\-]+)\s*;\s?(ISO[\w\-]+)$/i
|
159
134
|
# Microsoft helper:
|
160
135
|
# Handles 'type/subtype;ISO-8559-1'
|
161
|
-
"#{$1}/#{$2}; charset=#{quote_atom($3)}"
|
136
|
+
"#{$1}/#{$2}; charset=#{Utilities.quote_atom($3)}"
|
162
137
|
when val.chomp =~ /^text;?$/i
|
163
138
|
# Handles 'text;' and 'text'
|
164
139
|
"text/plain;"
|
@@ -167,7 +142,7 @@ module Mail
|
|
167
142
|
"text/plain; #{$2}"
|
168
143
|
when val =~ /([\w\-]+\/[\w\-]+);\scharset="charset="(\w+)""/i
|
169
144
|
# Handles text/html; charset="charset="GB2312""
|
170
|
-
"#{$1}; charset=#{quote_atom($2)}"
|
145
|
+
"#{$1}; charset=#{Utilities.quote_atom($2)}"
|
171
146
|
when val =~ /([\w\-]+\/[\w\-]+);\s+(.*)/i
|
172
147
|
type = $1
|
173
148
|
# Handles misquoted param values
|
@@ -176,7 +151,7 @@ module Mail
|
|
176
151
|
params = $2.to_s.split(/\s+/)
|
177
152
|
params = params.map { |i| i.to_s.chomp.strip }
|
178
153
|
params = params.map { |i| i.split(/\s*\=\s*/, 2) }
|
179
|
-
params = params.map { |i| "#{i[0]}=#{dquote(i[1].to_s.gsub(/;$/,""))}" }.join('; ')
|
154
|
+
params = params.map { |i| "#{i[0]}=#{Utilities.dquote(i[1].to_s.gsub(/;$/,""))}" }.join('; ')
|
180
155
|
"#{type}; #{params}"
|
181
156
|
when val =~ /^\s*$/
|
182
157
|
'text/plain'
|
@@ -185,9 +160,9 @@ module Mail
|
|
185
160
|
end
|
186
161
|
end
|
187
162
|
|
188
|
-
def get_mime_type(
|
189
|
-
case
|
190
|
-
when
|
163
|
+
def get_mime_type(val)
|
164
|
+
case val
|
165
|
+
when /^([\w\-]+)\/([\w\-]+);.+$/i
|
191
166
|
"#{$1}/#{$2}"
|
192
167
|
else
|
193
168
|
'text/plain'
|
@@ -1,57 +1,29 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
# frozen_string_literal: true
|
3
|
-
|
4
|
-
# = Date Field
|
5
|
-
#
|
6
|
-
# The Date field inherits from StructuredField and handles the Date: header
|
7
|
-
# field in the email.
|
8
|
-
#
|
9
|
-
# Sending date to a mail message will instantiate a Mail::Field object that
|
10
|
-
# has a DateField as its field type. This includes all Mail::CommonAddress
|
11
|
-
# module instance methods.
|
12
|
-
#
|
13
|
-
# There must be excatly one Date field in an RFC2822 email.
|
14
|
-
#
|
15
|
-
# == Examples:
|
16
|
-
#
|
17
|
-
# mail = Mail.new
|
18
|
-
# mail.date = 'Mon, 24 Nov 1997 14:22:01 -0800'
|
19
|
-
# mail.date #=> #<DateTime: 211747170121/86400,-1/3,2299161>
|
20
|
-
# mail.date.to_s #=> 'Mon, 24 Nov 1997 14:22:01 -0800'
|
21
|
-
# mail[:date] #=> '#<Mail::Field:0x180e5e8 @field=#<Mail::DateField:0x180e1c4
|
22
|
-
# mail['date'] #=> '#<Mail::Field:0x180e5e8 @field=#<Mail::DateField:0x180e1c4
|
23
|
-
# mail['Date'] #=> '#<Mail::Field:0x180e5e8 @field=#<Mail::DateField:0x180e1c4
|
24
|
-
#
|
25
|
-
require 'mail/fields/common/common_date'
|
3
|
+
require 'mail/fields/common_date_field'
|
26
4
|
|
27
5
|
module Mail
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
end
|
51
|
-
|
52
|
-
def decoded
|
53
|
-
do_decode
|
54
|
-
end
|
55
|
-
|
6
|
+
# = Date Field
|
7
|
+
#
|
8
|
+
# The Date field inherits from StructuredField and handles the Date: header
|
9
|
+
# field in the email.
|
10
|
+
#
|
11
|
+
# Sending date to a mail message will instantiate a Mail::Field object that
|
12
|
+
# has a DateField as its field type. This includes all Mail::CommonAddress
|
13
|
+
# module instance methods.
|
14
|
+
#
|
15
|
+
# There must be excatly one Date field in an RFC2822 email.
|
16
|
+
#
|
17
|
+
# == Examples:
|
18
|
+
#
|
19
|
+
# mail = Mail.new
|
20
|
+
# mail.date = 'Mon, 24 Nov 1997 14:22:01 -0800'
|
21
|
+
# mail.date #=> #<DateTime: 211747170121/86400,-1/3,2299161>
|
22
|
+
# mail.date.to_s #=> 'Mon, 24 Nov 1997 14:22:01 -0800'
|
23
|
+
# mail[:date] #=> '#<Mail::Field:0x180e5e8 @field=#<Mail::DateField:0x180e1c4
|
24
|
+
# mail['date'] #=> '#<Mail::Field:0x180e5e8 @field=#<Mail::DateField:0x180e1c4
|
25
|
+
# mail['Date'] #=> '#<Mail::Field:0x180e5e8 @field=#<Mail::DateField:0x180e1c4
|
26
|
+
class DateField < CommonDateField #:nodoc:
|
27
|
+
NAME = 'Date'
|
56
28
|
end
|
57
29
|
end
|
@@ -1,55 +1,34 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
# frozen_string_literal: true
|
3
|
-
|
4
|
-
# = From Field
|
5
|
-
#
|
6
|
-
# The From field inherits from StructuredField and handles the From: header
|
7
|
-
# field in the email.
|
8
|
-
#
|
9
|
-
# Sending from to a mail message will instantiate a Mail::Field object that
|
10
|
-
# has a FromField as its field type. This includes all Mail::CommonAddress
|
11
|
-
# module instance metods.
|
12
|
-
#
|
13
|
-
# Only one From field can appear in a header, though it can have multiple
|
14
|
-
# addresses and groups of addresses.
|
15
|
-
#
|
16
|
-
# == Examples:
|
17
|
-
#
|
18
|
-
# mail = Mail.new
|
19
|
-
# mail.from = 'Mikel Lindsaar <mikel@test.lindsaar.net>, ada@test.lindsaar.net'
|
20
|
-
# mail.from #=> ['mikel@test.lindsaar.net', 'ada@test.lindsaar.net']
|
21
|
-
# mail[:from] #=> '#<Mail::Field:0x180e5e8 @field=#<Mail::FromField:0x180e1c4
|
22
|
-
# mail['from'] #=> '#<Mail::Field:0x180e5e8 @field=#<Mail::FromField:0x180e1c4
|
23
|
-
# mail['From'] #=> '#<Mail::Field:0x180e5e8 @field=#<Mail::FromField:0x180e1c4
|
24
|
-
#
|
25
|
-
# mail[:from].encoded #=> 'from: Mikel Lindsaar <mikel@test.lindsaar.net>, ada@test.lindsaar.net\r\n'
|
26
|
-
# mail[:from].decoded #=> 'Mikel Lindsaar <mikel@test.lindsaar.net>, ada@test.lindsaar.net'
|
27
|
-
# mail[:from].addresses #=> ['mikel@test.lindsaar.net', 'ada@test.lindsaar.net']
|
28
|
-
# mail[:from].formatted #=> ['Mikel Lindsaar <mikel@test.lindsaar.net>', 'ada@test.lindsaar.net']
|
29
|
-
#
|
30
|
-
require 'mail/fields/common/common_address'
|
3
|
+
require 'mail/fields/common_address_field'
|
31
4
|
|
32
5
|
module Mail
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
6
|
+
# = From Field
|
7
|
+
#
|
8
|
+
# The From field inherits from StructuredField and handles the From: header
|
9
|
+
# field in the email.
|
10
|
+
#
|
11
|
+
# Sending from to a mail message will instantiate a Mail::Field object that
|
12
|
+
# has a FromField as its field type. This includes all Mail::CommonAddress
|
13
|
+
# module instance metods.
|
14
|
+
#
|
15
|
+
# Only one From field can appear in a header, though it can have multiple
|
16
|
+
# addresses and groups of addresses.
|
17
|
+
#
|
18
|
+
# == Examples:
|
19
|
+
#
|
20
|
+
# mail = Mail.new
|
21
|
+
# mail.from = 'Mikel Lindsaar <mikel@test.lindsaar.net>, ada@test.lindsaar.net'
|
22
|
+
# mail.from #=> ['mikel@test.lindsaar.net', 'ada@test.lindsaar.net']
|
23
|
+
# mail[:from] #=> '#<Mail::Field:0x180e5e8 @field=#<Mail::FromField:0x180e1c4
|
24
|
+
# mail['from'] #=> '#<Mail::Field:0x180e5e8 @field=#<Mail::FromField:0x180e1c4
|
25
|
+
# mail['From'] #=> '#<Mail::Field:0x180e5e8 @field=#<Mail::FromField:0x180e1c4
|
26
|
+
#
|
27
|
+
# mail[:from].encoded #=> 'from: Mikel Lindsaar <mikel@test.lindsaar.net>, ada@test.lindsaar.net\r\n'
|
28
|
+
# mail[:from].decoded #=> 'Mikel Lindsaar <mikel@test.lindsaar.net>, ada@test.lindsaar.net'
|
29
|
+
# mail[:from].addresses #=> ['mikel@test.lindsaar.net', 'ada@test.lindsaar.net']
|
30
|
+
# mail[:from].formatted #=> ['Mikel Lindsaar <mikel@test.lindsaar.net>', 'ada@test.lindsaar.net']
|
31
|
+
class FromField < CommonAddressField #:nodoc:
|
32
|
+
NAME = 'From'
|
54
33
|
end
|
55
34
|
end
|