mail 2.7.1.rc1 → 2.8.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (124) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +59 -28
  3. data/lib/mail/attachments_list.rb +2 -5
  4. data/lib/mail/body.rb +31 -48
  5. data/lib/mail/check_delivery_params.rb +21 -16
  6. data/lib/mail/constants.rb +27 -5
  7. data/lib/mail/elements/address.rb +27 -27
  8. data/lib/mail/elements/address_list.rb +1 -1
  9. data/lib/mail/elements/content_disposition_element.rb +1 -1
  10. data/lib/mail/elements/content_location_element.rb +1 -1
  11. data/lib/mail/elements/content_transfer_encoding_element.rb +1 -1
  12. data/lib/mail/elements/content_type_element.rb +8 -4
  13. data/lib/mail/elements/date_time_element.rb +1 -1
  14. data/lib/mail/elements/envelope_from_element.rb +13 -7
  15. data/lib/mail/elements/message_ids_element.rb +14 -5
  16. data/lib/mail/elements/mime_version_element.rb +1 -1
  17. data/lib/mail/elements/phrase_list.rb +7 -2
  18. data/lib/mail/elements/received_element.rb +20 -6
  19. data/lib/mail/encodings/7bit.rb +5 -0
  20. data/lib/mail/encodings/base64.rb +2 -2
  21. data/lib/mail/encodings/quoted_printable.rb +2 -2
  22. data/lib/mail/encodings/unix_to_unix.rb +1 -0
  23. data/lib/mail/encodings.rb +30 -59
  24. data/lib/mail/envelope.rb +11 -14
  25. data/lib/mail/field.rb +37 -53
  26. data/lib/mail/field_list.rb +60 -7
  27. data/lib/mail/fields/bcc_field.rb +34 -52
  28. data/lib/mail/fields/cc_field.rb +28 -49
  29. data/lib/mail/fields/comments_field.rb +27 -37
  30. data/lib/mail/fields/common_address_field.rb +170 -0
  31. data/lib/mail/fields/common_date_field.rb +58 -0
  32. data/lib/mail/fields/common_field.rb +77 -0
  33. data/lib/mail/fields/common_message_id_field.rb +42 -0
  34. data/lib/mail/fields/content_description_field.rb +7 -14
  35. data/lib/mail/fields/content_disposition_field.rb +13 -38
  36. data/lib/mail/fields/content_id_field.rb +24 -51
  37. data/lib/mail/fields/content_location_field.rb +11 -25
  38. data/lib/mail/fields/content_transfer_encoding_field.rb +31 -31
  39. data/lib/mail/fields/content_type_field.rb +46 -71
  40. data/lib/mail/fields/date_field.rb +23 -51
  41. data/lib/mail/fields/from_field.rb +28 -49
  42. data/lib/mail/fields/in_reply_to_field.rb +38 -49
  43. data/lib/mail/fields/keywords_field.rb +18 -31
  44. data/lib/mail/fields/message_id_field.rb +25 -71
  45. data/lib/mail/fields/mime_version_field.rb +19 -30
  46. data/lib/mail/fields/named_structured_field.rb +11 -0
  47. data/lib/mail/fields/named_unstructured_field.rb +11 -0
  48. data/lib/mail/fields/optional_field.rb +5 -6
  49. data/lib/mail/fields/{common/parameter_hash.rb → parameter_hash.rb} +12 -10
  50. data/lib/mail/fields/received_field.rb +43 -57
  51. data/lib/mail/fields/references_field.rb +35 -49
  52. data/lib/mail/fields/reply_to_field.rb +28 -49
  53. data/lib/mail/fields/resent_bcc_field.rb +28 -49
  54. data/lib/mail/fields/resent_cc_field.rb +28 -49
  55. data/lib/mail/fields/resent_date_field.rb +5 -29
  56. data/lib/mail/fields/resent_from_field.rb +28 -49
  57. data/lib/mail/fields/resent_message_id_field.rb +5 -29
  58. data/lib/mail/fields/resent_sender_field.rb +27 -56
  59. data/lib/mail/fields/resent_to_field.rb +28 -49
  60. data/lib/mail/fields/return_path_field.rb +50 -54
  61. data/lib/mail/fields/sender_field.rb +34 -55
  62. data/lib/mail/fields/structured_field.rb +3 -30
  63. data/lib/mail/fields/subject_field.rb +9 -11
  64. data/lib/mail/fields/to_field.rb +28 -49
  65. data/lib/mail/fields/unstructured_field.rb +16 -48
  66. data/lib/mail/header.rb +69 -110
  67. data/lib/mail/matchers/attachment_matchers.rb +15 -0
  68. data/lib/mail/message.rb +52 -66
  69. data/lib/mail/multibyte/chars.rb +8 -166
  70. data/lib/mail/multibyte/unicode.rb +10 -10
  71. data/lib/mail/multibyte/utils.rb +26 -43
  72. data/lib/mail/multibyte.rb +1 -11
  73. data/lib/mail/network/delivery_methods/exim.rb +5 -4
  74. data/lib/mail/network/delivery_methods/file_delivery.rb +11 -10
  75. data/lib/mail/network/delivery_methods/logger_delivery.rb +2 -5
  76. data/lib/mail/network/delivery_methods/sendmail.rb +56 -18
  77. data/lib/mail/network/delivery_methods/smtp.rb +25 -9
  78. data/lib/mail/network/delivery_methods/smtp_connection.rb +3 -12
  79. data/lib/mail/network/delivery_methods/test_mailer.rb +4 -2
  80. data/lib/mail/network/retriever_methods/base.rb +8 -8
  81. data/lib/mail/network/retriever_methods/imap.rb +3 -3
  82. data/lib/mail/network/retriever_methods/pop3.rb +2 -2
  83. data/lib/mail/network/retriever_methods/test_retriever.rb +2 -1
  84. data/lib/mail/parsers/address_lists_parser.rb +33175 -33140
  85. data/lib/mail/parsers/address_lists_parser.rl +7 -0
  86. data/lib/mail/parsers/content_disposition_parser.rb +889 -889
  87. data/lib/mail/parsers/content_disposition_parser.rl +7 -0
  88. data/lib/mail/parsers/content_location_parser.rb +796 -787
  89. data/lib/mail/parsers/content_location_parser.rl +7 -0
  90. data/lib/mail/parsers/content_transfer_encoding_parser.rb +496 -496
  91. data/lib/mail/parsers/content_transfer_encoding_parser.rl +7 -0
  92. data/lib/mail/parsers/content_type_parser.rb +1008 -1005
  93. data/lib/mail/parsers/content_type_parser.rl +7 -0
  94. data/lib/mail/parsers/date_time_parser.rb +864 -859
  95. data/lib/mail/parsers/date_time_parser.rl +7 -0
  96. data/lib/mail/parsers/envelope_from_parser.rb +3649 -3548
  97. data/lib/mail/parsers/envelope_from_parser.rl +7 -0
  98. data/lib/mail/parsers/message_ids_parser.rb +5135 -2832
  99. data/lib/mail/parsers/message_ids_parser.rl +12 -1
  100. data/lib/mail/parsers/mime_version_parser.rb +487 -483
  101. data/lib/mail/parsers/mime_version_parser.rl +7 -0
  102. data/lib/mail/parsers/phrase_lists_parser.rb +858 -865
  103. data/lib/mail/parsers/phrase_lists_parser.rl +8 -1
  104. data/lib/mail/parsers/received_parser.rb +8756 -8728
  105. data/lib/mail/parsers/received_parser.rl +7 -0
  106. data/lib/mail/parsers/rfc5322.rl +28 -13
  107. data/lib/mail/parsers.rb +11 -17
  108. data/lib/mail/part.rb +5 -9
  109. data/lib/mail/parts_list.rb +57 -0
  110. data/lib/mail/smtp_envelope.rb +57 -0
  111. data/lib/mail/utilities.rb +307 -69
  112. data/lib/mail/version.rb +2 -2
  113. data/lib/mail/yaml.rb +30 -0
  114. data/lib/mail.rb +3 -20
  115. metadata +88 -20
  116. data/lib/mail/core_extensions/smtp.rb +0 -28
  117. data/lib/mail/core_extensions/string.rb +0 -17
  118. data/lib/mail/fields/common/address_container.rb +0 -17
  119. data/lib/mail/fields/common/common_address.rb +0 -161
  120. data/lib/mail/fields/common/common_date.rb +0 -36
  121. data/lib/mail/fields/common/common_field.rb +0 -52
  122. data/lib/mail/fields/common/common_message_id.rb +0 -49
  123. data/lib/mail/version_specific/ruby_1_8.rb +0 -163
  124. 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.7.1.rc1
4
+ version: 2.8.1
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: 2018-03-01 00:00:00.000000000 Z
11
+ date: 2023-02-03 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
@@ -80,6 +136,20 @@ dependencies:
80
136
  - - ">="
81
137
  - !ruby/object:Gem::Version
82
138
  version: '0'
139
+ - !ruby/object:Gem::Dependency
140
+ name: rufo
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - ">="
144
+ - !ruby/object:Gem::Version
145
+ version: '0'
146
+ type: :development
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - ">="
151
+ - !ruby/object:Gem::Version
152
+ version: '0'
83
153
  description: A really Ruby Mail handler.
84
154
  email: raasdnil@gmail.com
85
155
  executables: []
@@ -95,8 +165,6 @@ files:
95
165
  - lib/mail/check_delivery_params.rb
96
166
  - lib/mail/configuration.rb
97
167
  - lib/mail/constants.rb
98
- - lib/mail/core_extensions/smtp.rb
99
- - lib/mail/core_extensions/string.rb
100
168
  - lib/mail/elements.rb
101
169
  - lib/mail/elements/address.rb
102
170
  - lib/mail/elements/address_list.rb
@@ -126,12 +194,10 @@ files:
126
194
  - lib/mail/fields/bcc_field.rb
127
195
  - lib/mail/fields/cc_field.rb
128
196
  - lib/mail/fields/comments_field.rb
129
- - lib/mail/fields/common/address_container.rb
130
- - lib/mail/fields/common/common_address.rb
131
- - lib/mail/fields/common/common_date.rb
132
- - lib/mail/fields/common/common_field.rb
133
- - lib/mail/fields/common/common_message_id.rb
134
- - lib/mail/fields/common/parameter_hash.rb
197
+ - lib/mail/fields/common_address_field.rb
198
+ - lib/mail/fields/common_date_field.rb
199
+ - lib/mail/fields/common_field.rb
200
+ - lib/mail/fields/common_message_id_field.rb
135
201
  - lib/mail/fields/content_description_field.rb
136
202
  - lib/mail/fields/content_disposition_field.rb
137
203
  - lib/mail/fields/content_id_field.rb
@@ -144,7 +210,10 @@ files:
144
210
  - lib/mail/fields/keywords_field.rb
145
211
  - lib/mail/fields/message_id_field.rb
146
212
  - lib/mail/fields/mime_version_field.rb
213
+ - lib/mail/fields/named_structured_field.rb
214
+ - lib/mail/fields/named_unstructured_field.rb
147
215
  - lib/mail/fields/optional_field.rb
216
+ - lib/mail/fields/parameter_hash.rb
148
217
  - lib/mail/fields/received_field.rb
149
218
  - lib/mail/fields/references_field.rb
150
219
  - lib/mail/fields/reply_to_field.rb
@@ -219,16 +288,16 @@ files:
219
288
  - lib/mail/parsers/rfc5322_lexical_tokens.rl
220
289
  - lib/mail/part.rb
221
290
  - lib/mail/parts_list.rb
291
+ - lib/mail/smtp_envelope.rb
222
292
  - lib/mail/utilities.rb
223
293
  - lib/mail/values/unicode_tables.dat
224
294
  - lib/mail/version.rb
225
- - lib/mail/version_specific/ruby_1_8.rb
226
- - lib/mail/version_specific/ruby_1_9.rb
295
+ - lib/mail/yaml.rb
227
296
  homepage: https://github.com/mikel/mail
228
297
  licenses:
229
298
  - MIT
230
299
  metadata: {}
231
- post_install_message:
300
+ post_install_message:
232
301
  rdoc_options:
233
302
  - "--exclude"
234
303
  - lib/mail/values/unicode_tables.dat
@@ -238,16 +307,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
238
307
  requirements:
239
308
  - - ">="
240
309
  - !ruby/object:Gem::Version
241
- version: '0'
310
+ version: '2.5'
242
311
  required_rubygems_version: !ruby/object:Gem::Requirement
243
312
  requirements:
244
- - - ">"
313
+ - - ">="
245
314
  - !ruby/object:Gem::Version
246
- version: 1.3.1
315
+ version: '0'
247
316
  requirements: []
248
- rubyforge_project:
249
- rubygems_version: 2.7.3
250
- signing_key:
317
+ rubygems_version: 3.1.6
318
+ signing_key:
251
319
  specification_version: 4
252
320
  summary: Mail provides a nice Ruby DSL for making, sending and reading emails.
253
321
  test_files: []
@@ -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,17 +0,0 @@
1
- # frozen_string_literal: true
2
- module Mail
3
-
4
- class AddressContainer < Array
5
-
6
- def initialize(field, list = [])
7
- @field = field
8
- super(list)
9
- end
10
-
11
- def <<(address)
12
- @field << address
13
- end
14
-
15
- end
16
-
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