net-imap 0.3.7 → 0.5.9

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.
Files changed (73) hide show
  1. checksums.yaml +4 -4
  2. data/BSDL +22 -0
  3. data/COPYING +56 -0
  4. data/Gemfile +15 -0
  5. data/LICENSE.txt +3 -22
  6. data/README.md +25 -8
  7. data/Rakefile +0 -7
  8. data/docs/styles.css +72 -23
  9. data/lib/net/imap/authenticators.rb +26 -57
  10. data/lib/net/imap/command_data.rb +74 -54
  11. data/lib/net/imap/config/attr_accessors.rb +75 -0
  12. data/lib/net/imap/config/attr_inheritance.rb +90 -0
  13. data/lib/net/imap/config/attr_type_coercion.rb +62 -0
  14. data/lib/net/imap/config.rb +552 -0
  15. data/lib/net/imap/connection_state.rb +48 -0
  16. data/lib/net/imap/data_encoding.rb +18 -6
  17. data/lib/net/imap/data_lite.rb +226 -0
  18. data/lib/net/imap/deprecated_client_options.rb +142 -0
  19. data/lib/net/imap/errors.rb +60 -1
  20. data/lib/net/imap/esearch_result.rb +180 -0
  21. data/lib/net/imap/fetch_data.rb +597 -0
  22. data/lib/net/imap/flags.rb +1 -1
  23. data/lib/net/imap/response_data.rb +249 -440
  24. data/lib/net/imap/response_parser/parser_utils.rb +245 -0
  25. data/lib/net/imap/response_parser.rb +1867 -1184
  26. data/lib/net/imap/response_reader.rb +73 -0
  27. data/lib/net/imap/sasl/anonymous_authenticator.rb +69 -0
  28. data/lib/net/imap/sasl/authentication_exchange.rb +139 -0
  29. data/lib/net/imap/sasl/authenticators.rb +122 -0
  30. data/lib/net/imap/sasl/client_adapter.rb +123 -0
  31. data/lib/net/imap/{authenticators/cram_md5.rb → sasl/cram_md5_authenticator.rb} +24 -14
  32. data/lib/net/imap/sasl/digest_md5_authenticator.rb +342 -0
  33. data/lib/net/imap/sasl/external_authenticator.rb +83 -0
  34. data/lib/net/imap/sasl/gs2_header.rb +80 -0
  35. data/lib/net/imap/{authenticators/login.rb → sasl/login_authenticator.rb} +28 -18
  36. data/lib/net/imap/sasl/oauthbearer_authenticator.rb +199 -0
  37. data/lib/net/imap/sasl/plain_authenticator.rb +101 -0
  38. data/lib/net/imap/sasl/protocol_adapters.rb +101 -0
  39. data/lib/net/imap/sasl/scram_algorithm.rb +58 -0
  40. data/lib/net/imap/sasl/scram_authenticator.rb +287 -0
  41. data/lib/net/imap/sasl/stringprep.rb +6 -66
  42. data/lib/net/imap/sasl/xoauth2_authenticator.rb +106 -0
  43. data/lib/net/imap/sasl.rb +148 -44
  44. data/lib/net/imap/sasl_adapter.rb +20 -0
  45. data/lib/net/imap/search_result.rb +146 -0
  46. data/lib/net/imap/sequence_set.rb +1871 -0
  47. data/lib/net/imap/stringprep/nameprep.rb +70 -0
  48. data/lib/net/imap/stringprep/saslprep.rb +69 -0
  49. data/lib/net/imap/stringprep/saslprep_tables.rb +96 -0
  50. data/lib/net/imap/stringprep/tables.rb +146 -0
  51. data/lib/net/imap/stringprep/trace.rb +85 -0
  52. data/lib/net/imap/stringprep.rb +159 -0
  53. data/lib/net/imap/uidplus_data.rb +244 -0
  54. data/lib/net/imap/vanished_data.rb +56 -0
  55. data/lib/net/imap.rb +2335 -867
  56. data/net-imap.gemspec +7 -8
  57. data/rakelib/benchmarks.rake +91 -0
  58. data/rakelib/rfcs.rake +2 -0
  59. data/rakelib/saslprep.rake +4 -4
  60. data/rakelib/string_prep_tables_generator.rb +86 -60
  61. data/sample/net-imap.rb +167 -0
  62. metadata +47 -49
  63. data/.github/dependabot.yml +0 -6
  64. data/.github/workflows/test.yml +0 -38
  65. data/.gitignore +0 -10
  66. data/benchmarks/stringprep.yml +0 -65
  67. data/benchmarks/table-regexps.yml +0 -39
  68. data/lib/net/imap/authenticators/digest_md5.rb +0 -115
  69. data/lib/net/imap/authenticators/plain.rb +0 -41
  70. data/lib/net/imap/authenticators/xoauth2.rb +0 -20
  71. data/lib/net/imap/sasl/saslprep.rb +0 -55
  72. data/lib/net/imap/sasl/saslprep_tables.rb +0 -98
  73. data/lib/net/imap/sasl/stringprep_tables.rb +0 -153
@@ -2,6 +2,14 @@
2
2
 
3
3
  module Net
4
4
  class IMAP < Protocol
5
+ autoload :ESearchResult, "#{__dir__}/esearch_result"
6
+ autoload :FetchData, "#{__dir__}/fetch_data"
7
+ autoload :UIDFetchData, "#{__dir__}/fetch_data"
8
+ autoload :SearchResult, "#{__dir__}/search_result"
9
+ autoload :UIDPlusData, "#{__dir__}/uidplus_data"
10
+ autoload :AppendUIDData, "#{__dir__}/uidplus_data"
11
+ autoload :CopyUIDData, "#{__dir__}/uidplus_data"
12
+ autoload :VanishedData, "#{__dir__}/vanished_data"
5
13
 
6
14
  # Net::IMAP::ContinuationRequest represents command continuation requests.
7
15
  #
@@ -55,17 +63,71 @@ module Net
55
63
 
56
64
  # Net::IMAP::IgnoredResponse represents intentionally ignored responses.
57
65
  #
58
- # This includes untagged response "NOOP" sent by eg. Zimbra to avoid some
59
- # clients to close the connection.
66
+ # This includes untagged response "NOOP" sent by e.g. Zimbra to avoid
67
+ # some clients to close the connection.
60
68
  #
61
69
  # It matches no IMAP standard.
70
+ class IgnoredResponse < UntaggedResponse
71
+ end
72
+
73
+ # **Note:** This represents an intentionally _unstable_ API. Where
74
+ # instances of this class are returned, future releases may return a
75
+ # different (incompatible) object <em>without deprecation or warning</em>.
76
+ #
77
+ # Net::IMAP::UnparsedData represents data for unknown response types or
78
+ # unknown extensions to response types without a well-defined extension
79
+ # grammar.
62
80
  #
63
- class IgnoredResponse < Struct.new(:raw_data)
81
+ # See also: UnparsedNumericResponseData, ExtensionData, IgnoredResponse
82
+ class UnparsedData < Struct.new(:unparsed_data)
64
83
  ##
65
- # method: raw_data
66
- # :call-seq: raw_data -> string
84
+ # method: unparsed_data
85
+ # :call-seq: unparsed_data -> string
67
86
  #
68
- # The raw response data.
87
+ # The unparsed data
88
+ end
89
+
90
+ # **Note:** This represents an intentionally _unstable_ API. Where
91
+ # instances of this class are returned, future releases may return a
92
+ # different (incompatible) object <em>without deprecation or warning</em>.
93
+ #
94
+ # Net::IMAP::UnparsedNumericResponseData represents data for unhandled
95
+ # response types with a numeric prefix. See the documentation for #number.
96
+ #
97
+ # See also: UnparsedData, ExtensionData, IgnoredResponse
98
+ class UnparsedNumericResponseData < Struct.new(:number, :unparsed_data)
99
+ ##
100
+ # method: number
101
+ # :call-seq: number -> integer
102
+ #
103
+ # Returns a numeric response data prefix, when available.
104
+ #
105
+ # Many response types are prefixed with a non-negative #number. For
106
+ # message data, #number may represent a sequence number or a UID. For
107
+ # mailbox data, #number may represent a message count.
108
+
109
+ ##
110
+ # method: unparsed_data
111
+ # :call-seq: unparsed_data -> string
112
+ #
113
+ # The unparsed data, not including #number or UntaggedResponse#name.
114
+ end
115
+
116
+ # **Note:** This represents an intentionally _unstable_ API. Where
117
+ # instances of this class are returned, future releases may return a
118
+ # different (incompatible) object <em>without deprecation or warning</em>.
119
+ #
120
+ # Net::IMAP::ExtensionData represents data that is parsable according to the
121
+ # forward-compatible extension syntax in RFC3501, RFC4466, or RFC9051, but
122
+ # isn't directly known or understood by Net::IMAP yet.
123
+ #
124
+ # See also: UnparsedData, UnparsedNumericResponseData, IgnoredResponse
125
+ class ExtensionData < Struct.new(:data)
126
+ ##
127
+ # method: data
128
+ # :call-seq: data -> string
129
+ #
130
+ # The parsed extension data.
69
131
  end
70
132
 
71
133
  # Net::IMAP::TaggedResponse represents tagged responses.
@@ -100,14 +162,24 @@ module Net
100
162
  # The raw response data.
101
163
  end
102
164
 
103
- # Net::IMAP::ResponseText represents texts of responses.
165
+ # ResponseText represents texts of responses.
104
166
  #
105
167
  # The text may be prefixed by a ResponseCode.
106
168
  #
107
- # ResponseText is returned from TaggedResponse#data, or from
108
- # UntaggedResponse#data when the response type is a "condition" ("OK", "NO",
109
- # "BAD", "PREAUTH", or "BYE").
169
+ # ResponseText is returned from TaggedResponse#data or
170
+ # UntaggedResponse#data for
171
+ # {"status responses"}[https://www.rfc-editor.org/rfc/rfc3501#section-7.1]:
172
+ # * every TaggedResponse, name[rdoc-ref:TaggedResponse#name] is always
173
+ # "+OK+", "+NO+", or "+BAD+".
174
+ # * any UntaggedResponse when name[rdoc-ref:UntaggedResponse#name] is
175
+ # "+OK+", "+NO+", "+BAD+", "+PREAUTH+", or "+BYE+".
176
+ #
177
+ # Note that these "status responses" are confusingly _not_ the same as the
178
+ # +STATUS+ UntaggedResponse (see IMAP#status and StatusData).
110
179
  class ResponseText < Struct.new(:code, :text)
180
+ # Used to avoid an allocation when ResponseText is empty
181
+ EMPTY = new(nil, "").freeze
182
+
111
183
  ##
112
184
  # method: code
113
185
  # :call-seq: code -> ResponseCode or nil
@@ -121,31 +193,35 @@ module Net
121
193
  # Returns the response text, not including any response code
122
194
  end
123
195
 
124
- # Net::IMAP::ResponseCode represents response codes. Response codes can be
125
- # retrieved from ResponseText#code and can be included in any "condition"
126
- # response: any TaggedResponse and UntaggedResponse when the response type
127
- # is a "condition" ("OK", "NO", "BAD", "PREAUTH", or "BYE").
196
+ # ResponseCode represents an \IMAP response code, which can be retrieved
197
+ # from ResponseText#code for
198
+ # {"status responses"}[https://www.rfc-editor.org/rfc/rfc3501#section-7.1]:
199
+ # * every TaggedResponse, name[rdoc-ref:TaggedResponse#name] is always
200
+ # "+OK+", "+NO+", or "+BAD+".
201
+ # * any UntaggedResponse when name[rdoc-ref:UntaggedResponse#name] is
202
+ # "+OK+", "+NO+", "+BAD+", "+PREAUTH+", or "+BYE+".
203
+ #
204
+ # Note that these "status responses" are confusingly _not_ the same as the
205
+ # +STATUS+ UntaggedResponse (see IMAP#status and StatusData).
128
206
  #
129
207
  # Some response codes come with additional data which will be parsed by
130
208
  # Net::IMAP. Others return +nil+ for #data, but are used as a
131
209
  # machine-readable annotation for the human-readable ResponseText#text in
132
- # the same response. When Net::IMAP does not know how to parse response
133
- # code text, #data returns the unparsed string.
210
+ # the same response.
134
211
  #
135
212
  # Untagged response code #data is pushed directly onto Net::IMAP#responses,
136
213
  # keyed by #name, unless it is removed by the command that generated it.
137
214
  # Use Net::IMAP#add_response_handler to view tagged response codes for
138
215
  # command methods that do not return their TaggedResponse.
139
216
  #
217
+ # == Standard response codes
218
+ #
140
219
  # \IMAP extensions may define new codes and the data that comes with them.
141
220
  # The IANA {IMAP Response
142
221
  # Codes}[https://www.iana.org/assignments/imap-response-codes/imap-response-codes.xhtml]
143
222
  # registry has links to specifications for all standard response codes.
144
- # Response codes are backwards compatible: Servers are allowed to send new
145
- # response codes even if the client has not enabled the extension that
146
- # defines them. When unknown response code data is encountered, #data
147
- # will return an unparsed string.
148
223
  #
224
+ # === +IMAP4rev1+ response codes
149
225
  # See [IMAP4rev1[https://www.rfc-editor.org/rfc/rfc3501]] {§7.1, "Server
150
226
  # Responses - Status
151
227
  # Responses"}[https://www.rfc-editor.org/rfc/rfc3501#section-7.1] for full
@@ -169,13 +245,32 @@ module Net
169
245
  # {§2.3.1.1, "Unique Identifier (UID) Message
170
246
  # Attribute}[https://www.rfc-editor.org/rfc/rfc3501#section-2.3.1.1].
171
247
  # * +UIDVALIDITY+, #data is an Integer, the UID validity value of the
172
- # mailbox See [{IMAP4rev1}[https://www.rfc-editor.org/rfc/rfc3501]],
248
+ # mailbox. See [{IMAP4rev1}[https://www.rfc-editor.org/rfc/rfc3501]],
173
249
  # {§2.3.1.1, "Unique Identifier (UID) Message
174
250
  # Attribute}[https://www.rfc-editor.org/rfc/rfc3501#section-2.3.1.1].
175
251
  # * +UNSEEN+, #data is an Integer, the number of messages which do not have
176
252
  # the <tt>\Seen</tt> flag set.
177
- #
178
- # See RFC5530[https://www.rfc-editor.org/rfc/rfc5530], "IMAP Response
253
+ # <em>DEPRECATED by IMAP4rev2.</em>
254
+ #
255
+ # === +BINARY+ extension
256
+ # See {[RFC3516]}[https://www.rfc-editor.org/rfc/rfc3516].
257
+ # * +UNKNOWN-CTE+, with a tagged +NO+ response, when the server does not
258
+ # known how to decode a CTE (content-transfer-encoding). #data is +nil+.
259
+ # See IMAP#fetch.
260
+ #
261
+ # === +UIDPLUS+ extension
262
+ # See {[RFC4315 §3]}[https://www.rfc-editor.org/rfc/rfc4315#section-3].
263
+ # * +APPENDUID+, #data is UIDPlusData. See IMAP#append.
264
+ # * +COPYUID+, #data is UIDPlusData. See IMAP#copy.
265
+ # * +UIDNOTSTICKY+, #data is +nil+. See IMAP#select.
266
+ #
267
+ # === +SEARCHRES+ extension
268
+ # See {[RFC5182]}[https://www.rfc-editor.org/rfc/rfc5182].
269
+ # * +NOTSAVED+, with a tagged +NO+ response, when the search result variable
270
+ # is not saved. #data is +nil+.
271
+ #
272
+ # === +RFC5530+ response codes
273
+ # See {[RFC5530]}[https://www.rfc-editor.org/rfc/rfc5530], "IMAP Response
179
274
  # Codes" for the definition of the following response codes, which are all
180
275
  # machine-readable annotations for the human-readable ResponseText#text, and
181
276
  # have +nil+ #data of their own:
@@ -197,6 +292,42 @@ module Net
197
292
  # * +ALREADYEXISTS+
198
293
  # * +NONEXISTENT+
199
294
  #
295
+ # === +QRESYNC+ extension
296
+ # See {[RFC7162]}[https://www.rfc-editor.org/rfc/rfc7162.html].
297
+ # * +CLOSED+, returned when the currently selected mailbox is closed
298
+ # implicitly by selecting or examining another mailbox. #data is +nil+.
299
+ #
300
+ # === +IMAP4rev2+ response codes
301
+ # See {[RFC9051]}[https://www.rfc-editor.org/rfc/rfc9051] {§7.1, "Server
302
+ # Responses - Status
303
+ # Responses"}[https://www.rfc-editor.org/rfc/rfc9051#section-7.1] for full
304
+ # descriptions of IMAP4rev2 response codes. IMAP4rev2 includes all of the
305
+ # response codes listed above (except "+UNSEEN+") and adds the following:
306
+ # * +HASCHILDREN+, with a tagged +NO+ response, when a mailbox delete failed
307
+ # because the server doesn't allow deletion of mailboxes with children.
308
+ # #data is +nil+.
309
+ #
310
+ # === +CONDSTORE+ extension
311
+ # See {[RFC7162]}[https://www.rfc-editor.org/rfc/rfc7162.html].
312
+ # * +NOMODSEQ+, when selecting a mailbox that does not support
313
+ # mod-sequences. #data is +nil+. See IMAP#select.
314
+ # * +HIGHESTMODSEQ+, #data is an Integer, the highest mod-sequence value of
315
+ # all messages in the mailbox. See IMAP#select.
316
+ # * +MODIFIED+, #data is a SequenceSet, the messages that have been modified
317
+ # since the +UNCHANGEDSINCE+ mod-sequence given to +STORE+ or <tt>UID
318
+ # STORE</tt>.
319
+ #
320
+ # === +OBJECTID+ extension
321
+ # See {[RFC8474]}[https://www.rfc-editor.org/rfc/rfc8474.html].
322
+ # * +MAILBOXID+, #data is a string
323
+ #
324
+ # == Extension compatibility
325
+ #
326
+ # Response codes are backwards compatible: Servers are allowed to send new
327
+ # response codes even if the client has not enabled the extension that
328
+ # defines them. When Net::IMAP does not know how to parse response
329
+ # code text, #data returns the unparsed string.
330
+ #
200
331
  class ResponseCode < Struct.new(:name, :data)
201
332
  ##
202
333
  # method: name
@@ -215,64 +346,8 @@ module Net
215
346
  # code data can take.
216
347
  end
217
348
 
218
- # Net::IMAP::UIDPlusData represents the ResponseCode#data that accompanies
219
- # the +APPENDUID+ and +COPYUID+ response codes.
220
- #
221
- # See [[UIDPLUS[https://www.rfc-editor.org/rfc/rfc4315.html]].
222
- #
223
- # ==== Capability requirement
224
- #
225
- # The +UIDPLUS+ capability[rdoc-ref:Net::IMAP#capability] must be supported.
226
- # A server that supports +UIDPLUS+ should send a UIDPlusData object inside
227
- # every TaggedResponse returned by the append[rdoc-ref:Net::IMAP#append],
228
- # copy[rdoc-ref:Net::IMAP#copy], move[rdoc-ref:Net::IMAP#move], {uid
229
- # copy}[rdoc-ref:Net::IMAP#uid_copy], and {uid
230
- # move}[rdoc-ref:Net::IMAP#uid_move] commands---unless the destination
231
- # mailbox reports +UIDNOTSTICKY+.
232
- #
233
- #--
234
- # TODO: support MULTIAPPEND
235
- #++
236
- #
237
- class UIDPlusData < Struct.new(:uidvalidity, :source_uids, :assigned_uids)
238
- ##
239
- # method: uidvalidity
240
- # :call-seq: uidvalidity -> nonzero uint32
241
- #
242
- # The UIDVALIDITY of the destination mailbox.
243
-
244
- ##
245
- # method: source_uids
246
- # :call-seq: source_uids -> nil or an array of nonzero uint32
247
- #
248
- # The UIDs of the copied or moved messages.
249
- #
250
- # Note:: Returns +nil+ for Net::IMAP#append.
251
-
252
- ##
253
- # method: assigned_uids
254
- # :call-seq: assigned_uids -> an array of nonzero uint32
255
- #
256
- # The newly assigned UIDs of the copied, moved, or appended messages.
257
- #
258
- # Note:: This always returns an array, even when it contains only one UID.
259
-
260
- ##
261
- # :call-seq: uid_mapping -> nil or a hash
262
- #
263
- # Returns a hash mapping each source UID to the newly assigned destination
264
- # UID.
265
- #
266
- # Note:: Returns +nil+ for Net::IMAP#append.
267
- def uid_mapping
268
- source_uids&.zip(assigned_uids)&.to_h
269
- end
270
- end
271
-
272
- # Net::IMAP::MailboxList represents contents of the LIST response,
273
- # representing a single mailbox path.
274
- #
275
- # Net::IMAP#list returns an array of MailboxList objects.
349
+ # MailboxList represents the data of an untagged +LIST+ response, for a
350
+ # _single_ mailbox path. IMAP#list returns an array of MailboxList objects.
276
351
  #
277
352
  class MailboxList < Struct.new(:attr, :delim, :name)
278
353
  ##
@@ -282,11 +357,11 @@ module Net
282
357
  # Returns the name attributes. Each name attribute is a symbol capitalized
283
358
  # by String#capitalize, such as :Noselect (not :NoSelect). For the
284
359
  # semantics of each attribute, see:
285
- # * rdoc-ref:Net::IMAP@Basic+Mailbox+Attributes
286
- # * rdoc-ref:Net::IMAP@Mailbox+role+Attributes
287
- # * Net::IMAP@SPECIAL-USE
360
+ # * Net::IMAP@Basic+Mailbox+Attributes
361
+ # * Net::IMAP@Mailbox+role+Attributes
288
362
  # * The IANA {IMAP Mailbox Name Attributes
289
363
  # registry}[https://www.iana.org/assignments/imap-mailbox-name-attributes/imap-mailbox-name-attributes.xhtml]
364
+ # has links to specifications for all standard mailbox attributes.
290
365
 
291
366
  ##
292
367
  # method: delim
@@ -301,16 +376,16 @@ module Net
301
376
  # Returns the mailbox name.
302
377
  end
303
378
 
304
- # Net::IMAP::MailboxQuota represents contents of GETQUOTA response.
305
- # This object can also be a response to GETQUOTAROOT. In the syntax
306
- # specification below, the delimiter used with the "#" construct is a
307
- # single space (SPACE).
379
+ # MailboxQuota represents the data of an untagged +QUOTA+ response.
308
380
  #
309
- # Net:IMAP#getquota returns an array of MailboxQuota objects.
381
+ # IMAP#getquota returns an array of MailboxQuota objects.
310
382
  #
311
383
  # Net::IMAP#getquotaroot returns an array containing both MailboxQuotaRoot
312
384
  # and MailboxQuota objects.
313
385
  #
386
+ # == Required capability
387
+ # Requires +QUOTA+ [RFC2087[https://www.rfc-editor.org/rfc/rfc2087]]
388
+ # capability.
314
389
  class MailboxQuota < Struct.new(:mailbox, :usage, :quota)
315
390
  ##
316
391
  # method: mailbox
@@ -332,12 +407,14 @@ module Net
332
407
  #
333
408
  end
334
409
 
335
- # Net::IMAP::MailboxQuotaRoot represents part of the GETQUOTAROOT
336
- # response. (GETQUOTAROOT can also return Net::IMAP::MailboxQuota.)
410
+ # MailboxQuotaRoot represents the data of an untagged +QUOTAROOT+ response.
337
411
  #
338
- # Net::IMAP#getquotaroot returns an array containing both MailboxQuotaRoot
339
- # and MailboxQuota objects.
412
+ # IMAP#getquotaroot returns an array containing both MailboxQuotaRoot and
413
+ # MailboxQuota objects.
340
414
  #
415
+ # == Required capability
416
+ # Requires +QUOTA+ [RFC2087[https://www.rfc-editor.org/rfc/rfc2087]]
417
+ # capability.
341
418
  class MailboxQuotaRoot < Struct.new(:mailbox, :quotaroots)
342
419
  ##
343
420
  # method: mailbox
@@ -352,12 +429,13 @@ module Net
352
429
  # Zero or more quotaroots that affect the quota on the specified mailbox.
353
430
  end
354
431
 
355
- # Net::IMAP::MailboxACLItem represents the response from GETACL.
432
+ # MailboxACLItem represents the data of an untagged +ACL+ response.
356
433
  #
357
- # Net::IMAP#getacl returns an array of MailboxACLItem objects.
434
+ # IMAP#getacl returns an array of MailboxACLItem objects.
358
435
  #
359
- # ==== Required capability
360
- # +ACL+ - described in [ACL[https://tools.ietf.org/html/rfc4314]]
436
+ # == Required capability
437
+ # Requires +ACL+ [RFC4314[https://www.rfc-editor.org/rfc/rfc4314]]
438
+ # capability.
361
439
  class MailboxACLItem < Struct.new(:user, :rights, :mailbox)
362
440
  ##
363
441
  # method: mailbox
@@ -379,11 +457,12 @@ module Net
379
457
  # The access rights the indicated #user has to the #mailbox.
380
458
  end
381
459
 
382
- # Net::IMAP::Namespace represents a single namespace contained inside a
383
- # NAMESPACE response.
384
- #
385
- # Returned by Net::IMAP#namespace, contained inside a Namespaces object.
460
+ # Namespace represents a _single_ namespace, contained inside a Namespaces
461
+ # object.
386
462
  #
463
+ # == Required capability
464
+ # Requires either +NAMESPACE+ [RFC2342[https://www.rfc-editor.org/rfc/rfc2342]]
465
+ # or +IMAP4rev2+ capability.
387
466
  class Namespace < Struct.new(:prefix, :delim, :extensions)
388
467
  ##
389
468
  # method: prefix
@@ -405,11 +484,14 @@ module Net
405
484
  # Extension parameter semantics would be defined by the extension.
406
485
  end
407
486
 
408
- # Net::IMAP::Namespaces represents a +NAMESPACE+ server response, which
409
- # contains lists of #personal, #shared, and #other namespaces.
487
+ # Namespaces represents the data of an untagged +NAMESPACE+ response,
488
+ # returned by IMAP#namespace.
410
489
  #
411
- # Net::IMAP#namespace returns a Namespaces object.
490
+ # Contains lists of #personal, #shared, and #other namespaces.
412
491
  #
492
+ # == Required capability
493
+ # Requires either +NAMESPACE+ [RFC2342[https://www.rfc-editor.org/rfc/rfc2342]]
494
+ # or +IMAP4rev2+ capability.
413
495
  class Namespaces < Struct.new(:personal, :other, :shared)
414
496
  ##
415
497
  # method: personal
@@ -430,9 +512,9 @@ module Net
430
512
  # Returns an array of Shared Namespace objects.
431
513
  end
432
514
 
433
- # Net::IMAP::StatusData represents the contents of the STATUS response.
515
+ # StatusData represents the contents of an untagged +STATUS+ response.
434
516
  #
435
- # Net::IMAP#status returns the contents of #attr.
517
+ # IMAP#status returns the contents of #attr.
436
518
  class StatusData < Struct.new(:mailbox, :attr)
437
519
  ##
438
520
  # method: mailbox
@@ -448,223 +530,20 @@ module Net
448
530
  # "UIDVALIDITY", "UNSEEN". Each value is a number.
449
531
  end
450
532
 
451
- # Net::IMAP::FetchData represents the contents of a FETCH response.
452
- #
453
- # Net::IMAP#fetch and Net::IMAP#uid_fetch both return an array of
454
- # FetchData objects.
455
- #
456
- # === Fetch attributes
457
- #
458
- #--
459
- # TODO: merge branch with accessor methods for each type of attr. Then
460
- # move nearly all of the +attr+ documentation onto the appropriate
461
- # accessor methods.
462
- #++
463
- #
464
- # Each key of the #attr hash is the data item name for the fetched value.
465
- # Each data item represents a message attribute, part of one, or an
466
- # interpretation of one. #seqno is not a message attribute. Most message
467
- # attributes are static and must never change for a given <tt>[server,
468
- # account, mailbox, UIDVALIDITY, UID]</tt> tuple. A few message attributes
469
- # can be dynamically changed, e.g. using the {STORE
470
- # command}[rdoc-ref:Net::IMAP#store].
471
- #
472
- # See {[IMAP4rev1] §7.4.2}[https://www.rfc-editor.org/rfc/rfc3501.html#section-7.4.2]
473
- # and {[IMAP4rev2] §7.5.2}[https://www.rfc-editor.org/rfc/rfc9051.html#section-7.5.2]
474
- # for full description of the standard fetch response data items, and
475
- # Net::IMAP@Message+envelope+and+body+structure for other relevant RFCs.
476
- #
477
- # ==== Static fetch data items
478
- #
479
- # The static data items
480
- # defined by [IMAP4rev1[https://www.rfc-editor.org/rfc/rfc3501.html]] are:
481
- #
482
- # [<tt>"UID"</tt>]
483
- # A number expressing the unique identifier of the message.
484
- #
485
- # [<tt>"BODY[]"</tt>, <tt>"BODY[]<#{offset}>"</tt>]
486
- # The [RFC5322[https://tools.ietf.org/html/rfc5322]] expression of the
487
- # entire message, as a string.
488
- #
489
- # If +offset+ is specified, this returned string is a substring of the
490
- # entire contents, starting at that origin octet. This means that
491
- # <tt>BODY[]<0></tt> MAY be truncated, but <tt>BODY[]</tt> is NEVER
492
- # truncated.
493
- #
494
- # <em>Messages can be parsed using the "mail" gem.</em>
495
- #
496
- # [Note]
497
- # When fetching <tt>BODY.PEEK[#{specifier}]</tt>, the data will be
498
- # returned in <tt>BODY[#{specifier}]</tt>, without the +PEEK+. This is
499
- # true for all of the <tt>BODY[...]</tt> attribute forms.
500
- #
501
- # [<tt>"BODY[HEADER]"</tt>, <tt>"BODY[HEADER]<#{offset}>"</tt>]
502
- # The [RFC5322[https://tools.ietf.org/html/rfc5322]] header of the
503
- # message.
504
- #
505
- # <em>Message headers can be parsed using the "mail" gem.</em>
506
- #
507
- # [<tt>"BODY[HEADER.FIELDS (#{fields.join(" ")})]"</tt>,]
508
- # [<tt>"BODY[HEADER.FIELDS (#{fields.join(" ")})]<#{offset}>"</tt>]
509
- # When field names are given, the subset contains only the header fields
510
- # that matches one of the names in the list. The field names are based
511
- # on what was requested, not on what was returned.
512
- #
513
- # [<tt>"BODY[HEADER.FIELDS.NOT (#{fields.join(" ")})]"</tt>,]
514
- # [<tt>"BODY[HEADER.FIELDS.NOT (#{fields.join(" ")})]<#{offset}>"</tt>]
515
- # When the <tt>HEADER.FIELDS.NOT</tt> is used, the subset is all of the
516
- # fields that <em>do not</em> match any names in the list.
517
- #
518
- # [<tt>"BODY[TEXT]"</tt>, <tt>"BODY[TEXT]<#{offset}>"</tt>]
519
- # The text body of the message, omitting
520
- # the [RFC5322[https://tools.ietf.org/html/rfc5322]] header.
521
- #
522
- # [<tt>"BODY[#{part}]"</tt>, <tt>"BODY[#{part}]<#{offset}>"</tt>]
523
- # The text of a particular body section, if it was fetched.
524
- #
525
- # Multiple part specifiers will be joined with <tt>"."</tt>. Numeric
526
- # part specifiers refer to the MIME part number, counting up from +1+.
527
- # Messages that don't use MIME, or MIME messages that are not multipart
528
- # and don't hold an encapsulated message, only have a part +1+.
529
- #
530
- # 8-bit textual data is permitted if
531
- # a [CHARSET[https://tools.ietf.org/html/rfc2978]] identifier is part of
532
- # the body parameter parenthesized list for this section. See
533
- # BodyTypeBasic.
534
- #
535
- # MESSAGE/RFC822 or MESSAGE/GLOBAL message, or a subset of the header, if
536
- # it was fetched.
537
- #
538
- # [<tt>"BODY[#{part}.HEADER]"</tt>,]
539
- # [<tt>"BODY[#{part}.HEADER]<#{offset}>"</tt>,]
540
- # [<tt>"BODY[#{part}.HEADER.FIELDS.NOT (#{fields.join(" ")})]"</tt>,]
541
- # [<tt>"BODY[#{part}.HEADER.FIELDS.NOT (#{fields.join(" ")})]<#{offset}>"</tt>,]
542
- # [<tt>"BODY[#{part}.TEXT]"</tt>,]
543
- # [<tt>"BODY[#{part}.TEXT]<#{offset}>"</tt>,]
544
- # [<tt>"BODY[#{part}.MIME]"</tt>,]
545
- # [<tt>"BODY[#{part}.MIME]<#{offset}>"</tt>]
546
- # +HEADER+, <tt>HEADER.FIELDS</tt>, <tt>HEADER.FIELDS.NOT</tt>, and
547
- # <tt>TEXT</tt> can be prefixed by numeric part specifiers, if it refers
548
- # to a part of type <tt>message/rfc822</tt> or <tt>message/global</tt>.
549
- #
550
- # +MIME+ refers to the [MIME-IMB[https://tools.ietf.org/html/rfc2045]]
551
- # header for this part.
552
- #
553
- # [<tt>"BODY"</tt>]
554
- # A form of +BODYSTRUCTURE+, without any extension data.
555
- #
556
- # [<tt>"BODYSTRUCTURE"</tt>]
557
- # Returns a BodyStructure object that describes
558
- # the [MIME-IMB[https://tools.ietf.org/html/rfc2045]] body structure of
559
- # a message, if it was fetched.
560
- #
561
- # [<tt>"ENVELOPE"</tt>]
562
- # An Envelope object that describes the envelope structure of a message.
563
- # See the documentation for Envelope for a description of the envelope
564
- # structure attributes.
565
- #
566
- # [<tt>"INTERNALDATE"</tt>]
567
- # The internal date and time of the message on the server. This is not
568
- # the date and time in
569
- # the [RFC5322[https://tools.ietf.org/html/rfc5322]] header, but rather
570
- # a date and time which reflects when the message was received.
571
- #
572
- # [<tt>"RFC822.SIZE"</tt>]
573
- # A number expressing the [RFC5322[https://tools.ietf.org/html/rfc5322]]
574
- # size of the message.
575
- #
576
- # [Note]
577
- # \IMAP was originally developed for the older RFC-822 standard, and
578
- # as a consequence several fetch items in \IMAP incorporate "RFC822"
579
- # in their name. With the exception of +RFC822.SIZE+, there are more
580
- # modern replacements; for example, the modern version of
581
- # +RFC822.HEADER+ is <tt>BODY.PEEK[HEADER]</tt>. In all cases,
582
- # "RFC822" should be interpreted as a reference to the
583
- # updated [RFC5322[https://tools.ietf.org/html/rfc5322]] standard.
584
- #
585
- # [<tt>"RFC822"</tt>]
586
- # Semantically equivalent to <tt>BODY[]</tt>.
587
- # [<tt>"RFC822.HEADER"</tt>]
588
- # Semantically equivalent to <tt>BODY[HEADER]</tt>.
589
- # [<tt>"RFC822.TEXT"</tt>]
590
- # Semantically equivalent to <tt>BODY[TEXT]</tt>.
591
- #
592
- # [Note:]
593
- # >>>
594
- # Additional static fields are defined in \IMAP extensions and
595
- # [IMAP4rev2[https://www.rfc-editor.org/rfc/rfc9051.html]], but
596
- # Net::IMAP can't parse them yet.
597
- #
598
- #--
599
- # <tt>"BINARY[#{section_binary}]<#{offset}>"</tt>:: TODO...
600
- # <tt>"BINARY.SIZE[#{sectionbinary}]"</tt>:: TODO...
601
- # <tt>"EMAILID"</tt>:: TODO...
602
- # <tt>"THREADID"</tt>:: TODO...
603
- # <tt>"SAVEDATE"</tt>:: TODO...
604
- #++
605
- #
606
- # ==== Dynamic message attributes
607
- # The only dynamic item defined
608
- # by [{IMAP4rev1}[https://www.rfc-editor.org/rfc/rfc3501.html]] is:
609
- # [<tt>"FLAGS"</tt>]
610
- # An array of flags that are set for this message. System flags are
611
- # symbols that have been capitalized by String#capitalize. Keyword
612
- # flags are strings and their case is not changed.
613
- #
614
- # \IMAP extensions define new dynamic fields, e.g.:
615
- #
616
- # [<tt>"MODSEQ"</tt>]
617
- # The modification sequence number associated with this IMAP message.
618
- #
619
- # Requires the [CONDSTORE[https://tools.ietf.org/html/rfc7162]]
620
- # server {capability}[rdoc-ref:Net::IMAP#capability].
621
- #
622
- # [Note:]
623
- # >>>
624
- # Additional dynamic fields are defined in \IMAP extensions, but
625
- # Net::IMAP can't parse them yet.
626
- #
627
- #--
628
- # <tt>"ANNOTATE"</tt>:: TODO...
629
- # <tt>"PREVIEW"</tt>:: TODO...
630
- #++
631
- #
632
- class FetchData < Struct.new(:seqno, :attr)
633
- ##
634
- # method: seqno
635
- # :call-seq: seqno -> Integer
636
- #
637
- # The message sequence number.
638
- #
639
- # [Note]
640
- # This is never the unique identifier (UID), not even for the
641
- # Net::IMAP#uid_fetch result. If it was returned, the UID is available
642
- # from <tt>attr["UID"]</tt>.
643
-
644
- ##
645
- # method: attr
646
- # :call-seq: attr -> hash
647
- #
648
- # A hash. Each key is specifies a message attribute, and the value is the
649
- # corresponding data item.
650
- #
651
- # See rdoc-ref:FetchData@Fetch+attributes for descriptions of possible
652
- # values.
653
- end
654
-
655
533
  # Net::IMAP::Envelope represents envelope structures of messages.
656
534
  #
657
535
  # [Note]
658
536
  # When the #sender and #reply_to fields are absent or empty, they will
659
537
  # return the same value as #from. Also, fields may return values that are
660
- # invalid for well-formed [RFC5322[https://tools.ietf.org/html/rfc5322]]
538
+ # invalid for well-formed [RFC5322[https://www.rfc-editor.org/rfc/rfc5322]]
661
539
  # messages when the message is malformed or a draft message.
662
540
  #
663
- # See [{IMAP4rev1 §7.4.2}[https://www.rfc-editor.org/rfc/rfc3501.html#section-7.4.2]]
664
- # and [{IMAP4rev2 §7.5.2}[https://www.rfc-editor.org/rfc/rfc9051.html#section-7.5.2]]
541
+ # See [{IMAP4rev1 §7.4.2}[https://www.rfc-editor.org/rfc/rfc3501#section-7.4.2]]
542
+ # and [{IMAP4rev2 §7.5.2}[https://www.rfc-editor.org/rfc/rfc9051#section-7.5.2]]
665
543
  # for full description of the envelope fields, and
666
544
  # Net::IMAP@Message+envelope+and+body+structure for other relevant RFCs.
667
545
  #
546
+ # Returned by FetchData#envelope
668
547
  class Envelope < Struct.new(:date, :subject, :from, :sender, :reply_to,
669
548
  :to, :cc, :bcc, :in_reply_to, :message_id)
670
549
  ##
@@ -674,7 +553,7 @@ module Net
674
553
  # Returns a string that represents the +Date+ header.
675
554
  #
676
555
  # [Note]
677
- # For a well-formed [RFC5322[https://tools.ietf.org/html/rfc5322]]
556
+ # For a well-formed [RFC5322[https://www.rfc-editor.org/rfc/rfc5322]]
678
557
  # message, the #date field must not be +nil+. However it can be +nil+
679
558
  # for a malformed or draft message.
680
559
 
@@ -700,7 +579,7 @@ module Net
700
579
  # returns +nil+ for this envelope field.
701
580
  #
702
581
  # [Note]
703
- # For a well-formed [RFC5322[https://tools.ietf.org/html/rfc5322]]
582
+ # For a well-formed [RFC5322[https://www.rfc-editor.org/rfc/rfc5322]]
704
583
  # message, the #from field must not be +nil+. However it can be +nil+
705
584
  # for a malformed or draft message.
706
585
 
@@ -713,7 +592,7 @@ module Net
713
592
  # [Note]
714
593
  # If the <tt>Sender</tt> header is absent, or is present but empty, the
715
594
  # server sets this field to be the same value as #from. Therefore, in a
716
- # well-formed [RFC5322[https://tools.ietf.org/html/rfc5322]] message,
595
+ # well-formed [RFC5322[https://www.rfc-editor.org/rfc/rfc5322]] message,
717
596
  # the #sender envelope field must not be +nil+. However it can be
718
597
  # +nil+ for a malformed or draft message.
719
598
 
@@ -727,7 +606,7 @@ module Net
727
606
  # [Note]
728
607
  # If the <tt>Reply-To</tt> header is absent, or is present but empty,
729
608
  # the server sets this field to be the same value as #from. Therefore,
730
- # in a well-formed [RFC5322[https://tools.ietf.org/html/rfc5322]]
609
+ # in a well-formed [RFC5322[https://www.rfc-editor.org/rfc/rfc5322]]
731
610
  # message, the #reply_to envelope field must not be +nil+. However it
732
611
  # can be +nil+ for a malformed or draft message.
733
612
 
@@ -756,7 +635,7 @@ module Net
756
635
  # Returns a string that represents the <tt>In-Reply-To</tt> header.
757
636
  #
758
637
  # [Note]
759
- # For a well-formed [RFC5322[https://tools.ietf.org/html/rfc5322]]
638
+ # For a well-formed [RFC5322[https://www.rfc-editor.org/rfc/rfc5322]]
760
639
  # message, the #in_reply_to field, if present, must not be empty. But
761
640
  # it can still return an empty string for malformed messages.
762
641
  #
@@ -772,7 +651,7 @@ module Net
772
651
  # Returns a string that represents the <tt>Message-ID</tt>.
773
652
  #
774
653
  # [Note]
775
- # For a well-formed [RFC5322[https://tools.ietf.org/html/rfc5322]]
654
+ # For a well-formed [RFC5322[https://www.rfc-editor.org/rfc/rfc5322]]
776
655
  # message, the #message_id field, if present, must not be empty. But it
777
656
  # can still return an empty string for malformed messages.
778
657
  #
@@ -786,10 +665,10 @@ module Net
786
665
  # parsed into its component parts by the server. Address objects are
787
666
  # returned within Envelope fields.
788
667
  #
789
- # === Group syntax
668
+ # == Group syntax
790
669
  #
791
670
  # When the #host field is +nil+, this is a special form of address structure
792
- # that indicates the [RFC5322[https://tools.ietf.org/html/rfc5322]] group
671
+ # that indicates the [RFC5322[https://www.rfc-editor.org/rfc/rfc5322]] group
793
672
  # syntax. If the #mailbox name field is also +nil+, this is an end-of-group
794
673
  # marker (semicolon in RFC-822 syntax). If the #mailbox name field is
795
674
  # non-+NIL+, this is the start of a group marker, and the mailbox #name
@@ -799,7 +678,7 @@ module Net
799
678
  # method: name
800
679
  # :call-seq: name -> string or nil
801
680
  #
802
- # Returns the [RFC5322[https://tools.ietf.org/html/rfc5322]] address
681
+ # Returns the [RFC5322[https://www.rfc-editor.org/rfc/rfc5322]] address
803
682
  # +display-name+ (or the mailbox +phrase+ in the RFC-822 grammar).
804
683
 
805
684
  ##
@@ -809,28 +688,28 @@ module Net
809
688
  # Returns the route from RFC-822 route-addr.
810
689
  #
811
690
  # Note:: Generating this obsolete route addressing syntax is not allowed
812
- # by [RFC5322[https://tools.ietf.org/html/rfc5322]]. However,
691
+ # by [RFC5322[https://www.rfc-editor.org/rfc/rfc5322]]. However,
813
692
  # addresses with this syntax must still be accepted and parsed.
814
693
 
815
694
  ##
816
695
  # method: mailbox
817
696
  # :call-seq: mailbox -> string or nil
818
697
  #
819
- # Returns the [RFC5322[https://tools.ietf.org/html/rfc5322]] address
698
+ # Returns the [RFC5322[https://www.rfc-editor.org/rfc/rfc5322]] address
820
699
  # +local-part+, if #host is not +nil+.
821
700
  #
822
701
  # When #host is +nil+, this returns
823
- # an [RFC5322[https://tools.ietf.org/html/rfc5322]] group name and a +nil+
702
+ # an [RFC5322[https://www.rfc-editor.org/rfc/rfc5322]] group name and a +nil+
824
703
  # mailbox indicates the end of a group.
825
704
 
826
705
  ##
827
706
  # method: host
828
707
  # :call-seq: host -> string or nil
829
708
  #
830
- # Returns the [RFC5322[https://tools.ietf.org/html/rfc5322]] addr-spec
709
+ # Returns the [RFC5322[https://www.rfc-editor.org/rfc/rfc5322]] addr-spec
831
710
  # +domain+ name.
832
711
  #
833
- # +nil+ indicates [RFC5322[https://tools.ietf.org/html/rfc5322]] group
712
+ # +nil+ indicates [RFC5322[https://www.rfc-editor.org/rfc/rfc5322]] group
834
713
  # syntax.
835
714
  end
836
715
 
@@ -842,14 +721,14 @@ module Net
842
721
  # :call-seq: dsp_type -> string
843
722
  #
844
723
  # Returns the content disposition type, as defined by
845
- # [DISPOSITION[https://tools.ietf.org/html/rfc2183]].
724
+ # [DISPOSITION[https://www.rfc-editor.org/rfc/rfc2183]].
846
725
 
847
726
  ##
848
727
  # method: param
849
728
  # :call-seq: param -> hash
850
729
  #
851
730
  # Returns a hash representing parameters of the Content-Disposition
852
- # field, as defined by [DISPOSITION[https://tools.ietf.org/html/rfc2183]].
731
+ # field, as defined by [DISPOSITION[https://www.rfc-editor.org/rfc/rfc2183]].
853
732
  end
854
733
 
855
734
  # Net::IMAP::ThreadMember represents a thread-node returned
@@ -868,6 +747,19 @@ module Net
868
747
  #
869
748
  # An array of Net::IMAP::ThreadMember objects for mail items that are
870
749
  # children of this in the thread.
750
+
751
+ # Returns a SequenceSet containing #seqno and all #children's seqno,
752
+ # recursively.
753
+ def to_sequence_set
754
+ SequenceSet.new all_seqnos
755
+ end
756
+
757
+ protected
758
+
759
+ def all_seqnos(node = self)
760
+ [node.seqno].concat node.children.flat_map { _1.all_seqnos }
761
+ end
762
+
871
763
  end
872
764
 
873
765
  # Net::IMAP::BodyStructure is included by all of the structs that can be
@@ -875,12 +767,12 @@ module Net
875
767
  # FetchData#attr value. Although these classes don't share a base class,
876
768
  # this module can be used to pattern match all of them.
877
769
  #
878
- # See {[IMAP4rev1] §7.4.2}[https://www.rfc-editor.org/rfc/rfc3501.html#section-7.4.2]
879
- # and {[IMAP4rev2] §7.5.2}[https://www.rfc-editor.org/rfc/rfc9051.html#section-7.5.2-4.9]
770
+ # See {[IMAP4rev1] §7.4.2}[https://www.rfc-editor.org/rfc/rfc3501#section-7.4.2]
771
+ # and {[IMAP4rev2] §7.5.2}[https://www.rfc-editor.org/rfc/rfc9051#section-7.5.2-4.9]
880
772
  # for full description of all +BODYSTRUCTURE+ fields, and also
881
773
  # Net::IMAP@Message+envelope+and+body+structure for other relevant RFCs.
882
774
  #
883
- # === Classes that include BodyStructure
775
+ # == Classes that include BodyStructure
884
776
  # BodyTypeBasic:: Represents any message parts that are not handled by
885
777
  # BodyTypeText, BodyTypeMessage, or BodyTypeMultipart.
886
778
  # BodyTypeText:: Used by <tt>text/*</tt> parts. Contains all of the
@@ -891,13 +783,6 @@ module Net
891
783
  # should use BodyTypeBasic.
892
784
  # BodyTypeMultipart:: for <tt>multipart/*</tt> parts
893
785
  #
894
- # ==== Deprecated BodyStructure classes
895
- # The following classes represent invalid server responses or parser bugs:
896
- # BodyTypeExtension:: parser bug: used for <tt>message/*</tt> where
897
- # BodyTypeBasic should have been used.
898
- # BodyTypeAttachment:: server bug: some servers sometimes return the
899
- # "Content-Disposition: attachment" data where the
900
- # entire body structure for a message part is expected.
901
786
  module BodyStructure
902
787
  end
903
788
 
@@ -905,8 +790,8 @@ module Net
905
790
  # message parts, unless they have a <tt>Content-Type</tt> that is handled by
906
791
  # BodyTypeText, BodyTypeMessage, or BodyTypeMultipart.
907
792
  #
908
- # See {[IMAP4rev1] §7.4.2}[https://www.rfc-editor.org/rfc/rfc3501.html#section-7.4.2]
909
- # and {[IMAP4rev2] §7.5.2}[https://www.rfc-editor.org/rfc/rfc9051.html#section-7.5.2-4.9]
793
+ # See {[IMAP4rev1] §7.4.2}[https://www.rfc-editor.org/rfc/rfc3501#section-7.4.2]
794
+ # and {[IMAP4rev2] §7.5.2}[https://www.rfc-editor.org/rfc/rfc9051#section-7.5.2-4.9]
910
795
  # for full description of all +BODYSTRUCTURE+ fields, and also
911
796
  # Net::IMAP@Message+envelope+and+body+structure for other relevant RFCs.
912
797
  #
@@ -914,6 +799,7 @@ module Net
914
799
  :param, :content_id,
915
800
  :description, :encoding, :size,
916
801
  :md5, :disposition, :language,
802
+ :location,
917
803
  :extension)
918
804
  include BodyStructure
919
805
 
@@ -922,45 +808,45 @@ module Net
922
808
  # :call-seq: media_type -> string
923
809
  #
924
810
  # The top-level media type as defined in
925
- # [MIME-IMB[https://tools.ietf.org/html/rfc2045]].
811
+ # [MIME-IMB[https://www.rfc-editor.org/rfc/rfc2045]].
926
812
 
927
813
  ##
928
814
  # method: subtype
929
815
  # :call-seq: subtype -> string
930
816
  #
931
817
  # The media subtype name as defined in
932
- # [MIME-IMB[https://tools.ietf.org/html/rfc2045]].
818
+ # [MIME-IMB[https://www.rfc-editor.org/rfc/rfc2045]].
933
819
 
934
820
  ##
935
821
  # method: param
936
822
  # :call-seq: param -> string
937
823
  #
938
824
  # Returns a hash that represents parameters as defined in
939
- # [MIME-IMB[https://tools.ietf.org/html/rfc2045]].
825
+ # [MIME-IMB[https://www.rfc-editor.org/rfc/rfc2045]].
940
826
 
941
827
  ##
942
828
  # method: content_id
943
829
  # :call-seq: content_id -> string
944
830
  #
945
831
  # Returns a string giving the content id as defined
946
- # in [MIME-IMB[https://tools.ietf.org/html/rfc2045]]
947
- # {§7}[https://tools.ietf.org/html/rfc2045#section-7].
832
+ # in [MIME-IMB[https://www.rfc-editor.org/rfc/rfc2045]]
833
+ # {§7}[https://www.rfc-editor.org/rfc/rfc2045#section-7].
948
834
 
949
835
  ##
950
836
  # method: description
951
837
  # :call-seq: description -> string
952
838
  #
953
839
  # Returns a string giving the content description as defined
954
- # in [MIME-IMB[https://tools.ietf.org/html/rfc2045]]
955
- # {§8}[https://tools.ietf.org/html/rfc2045#section-8].
840
+ # in [MIME-IMB[https://www.rfc-editor.org/rfc/rfc2045]]
841
+ # {§8}[https://www.rfc-editor.org/rfc/rfc2045#section-8].
956
842
 
957
843
  ##
958
844
  # method: encoding
959
845
  # :call-seq: encoding -> string
960
846
  #
961
847
  # Returns a string giving the content transfer encoding as defined
962
- # in [MIME-IMB[https://tools.ietf.org/html/rfc2045]]
963
- # {§6}[https://tools.ietf.org/html/rfc2045#section-6].
848
+ # in [MIME-IMB[https://www.rfc-editor.org/rfc/rfc2045]]
849
+ # {§6}[https://www.rfc-editor.org/rfc/rfc2045#section-6].
964
850
 
965
851
  ##
966
852
  # method: size
@@ -973,7 +859,7 @@ module Net
973
859
  # :call-seq: md5 -> string
974
860
  #
975
861
  # Returns a string giving the body MD5 value as defined in
976
- # [MD5[https://tools.ietf.org/html/rfc1864]].
862
+ # [MD5[https://www.rfc-editor.org/rfc/rfc1864]].
977
863
 
978
864
  ##
979
865
  # method: disposition
@@ -981,7 +867,7 @@ module Net
981
867
  #
982
868
  # Returns a ContentDisposition object giving the content
983
869
  # disposition, as defined by
984
- # [DISPOSITION[https://tools.ietf.org/html/rfc2183]].
870
+ # [DISPOSITION[https://www.rfc-editor.org/rfc/rfc2183]].
985
871
 
986
872
  ##
987
873
  # method: language
@@ -1026,7 +912,8 @@ module Net
1026
912
  # for something else?
1027
913
  #++
1028
914
  def media_subtype
1029
- warn("media_subtype is obsolete, use subtype instead.\n", uplevel: 1)
915
+ warn("media_subtype is obsolete, use subtype instead.\n",
916
+ uplevel: 1, category: :deprecated)
1030
917
  return subtype
1031
918
  end
1032
919
  end
@@ -1049,6 +936,7 @@ module Net
1049
936
  :description, :encoding, :size,
1050
937
  :lines,
1051
938
  :md5, :disposition, :language,
939
+ :location,
1052
940
  :extension)
1053
941
  include BodyStructure
1054
942
 
@@ -1070,7 +958,8 @@ module Net
1070
958
  # generate a warning message to +stderr+, then return
1071
959
  # the value of +subtype+.
1072
960
  def media_subtype
1073
- warn("media_subtype is obsolete, use subtype instead.\n", uplevel: 1)
961
+ warn("media_subtype is obsolete, use subtype instead.\n",
962
+ uplevel: 1, category: :deprecated)
1074
963
  return subtype
1075
964
  end
1076
965
  end
@@ -1088,12 +977,12 @@ module Net
1088
977
  # * description[rdoc-ref:BodyTypeBasic#description]
1089
978
  # * encoding[rdoc-ref:BodyTypeBasic#encoding]
1090
979
  # * size[rdoc-ref:BodyTypeBasic#size]
1091
- #
1092
980
  class BodyTypeMessage < Struct.new(:media_type, :subtype,
1093
981
  :param, :content_id,
1094
982
  :description, :encoding, :size,
1095
983
  :envelope, :body, :lines,
1096
984
  :md5, :disposition, :language,
985
+ :location,
1097
986
  :extension)
1098
987
  include BodyStructure
1099
988
 
@@ -1126,75 +1015,12 @@ module Net
1126
1015
  end
1127
1016
  end
1128
1017
 
1129
- # === WARNING
1130
- # BodyTypeAttachment represents a <tt>body-fld-dsp</tt> that is
1131
- # incorrectly in a position where the IMAP4rev1 grammar expects a nested
1132
- # +body+ structure.
1133
- #
1134
- # >>>
1135
- # \IMAP body structures are parenthesized lists and assign their fields
1136
- # positionally, so missing fields change the intepretation of all
1137
- # following fields. Buggy \IMAP servers sometimes leave fields missing
1138
- # rather than empty, which inevitably confuses parsers.
1139
- # BodyTypeAttachment was an attempt to parse a common type of buggy body
1140
- # structure without crashing.
1141
- #
1142
- # Currently, when Net::IMAP::ResponseParser sees "attachment" as the first
1143
- # entry in a <tt>body-type-1part</tt>, which is where the MIME type should
1144
- # be, it uses BodyTypeAttachment to capture the rest. "attachment" is not
1145
- # a valid MIME type, but _is_ a common <tt>Content-Disposition</tt>. What
1146
- # might have happened was that buggy server could not parse the message
1147
- # (which might have been incorrectly formatted) and output a
1148
- # <tt>body-type-dsp</tt> where a Net::IMAP::ResponseParser expected to see
1149
- # a +body+.
1150
- #
1151
- # A future release will replace this, probably with a ContentDisposition
1152
- # nested inside another body structure object, maybe BodyTypeBasic, or
1153
- # perhaps a new body structure class that represents any unparsable body
1154
- # structure.
1155
- #
1156
- class BodyTypeAttachment < Struct.new(:dsp_type, :_unused_, :param)
1157
- include BodyStructure
1158
-
1159
- # *invalid for BodyTypeAttachment*
1160
- def media_type
1161
- warn(<<~WARN, uplevel: 1)
1162
- BodyTypeAttachment#media_type is obsolete. Use dsp_type instead.
1163
- WARN
1164
- dsp_type
1165
- end
1166
-
1167
- # *invalid for BodyTypeAttachment*
1168
- def subtype
1169
- warn("BodyTypeAttachment#subtype is obsolete.\n", uplevel: 1)
1170
- nil
1171
- end
1172
-
1173
- ##
1174
- # method: dsp_type
1175
- # :call-seq: dsp_type -> string
1176
- #
1177
- # Returns the content disposition type, as defined by
1178
- # [DISPOSITION[https://tools.ietf.org/html/rfc2183]].
1179
-
1180
- ##
1181
- # method: param
1182
- # :call-seq: param -> hash
1183
- #
1184
- # Returns a hash representing parameters of the Content-Disposition
1185
- # field, as defined by [DISPOSITION[https://tools.ietf.org/html/rfc2183]].
1186
-
1187
- ##
1188
- def multipart?
1189
- return false
1190
- end
1191
- end
1192
-
1193
1018
  # Net::IMAP::BodyTypeMultipart represents body structures of messages and
1194
1019
  # message parts, when <tt>Content-Type</tt> is <tt>multipart/*</tt>.
1195
1020
  class BodyTypeMultipart < Struct.new(:media_type, :subtype,
1196
1021
  :parts,
1197
1022
  :param, :disposition, :language,
1023
+ :location,
1198
1024
  :extension)
1199
1025
  include BodyStructure
1200
1026
 
@@ -1209,7 +1035,7 @@ module Net
1209
1035
  # call-seq: subtype -> string
1210
1036
  #
1211
1037
  # Returns the content subtype name
1212
- # as defined in [MIME-IMB[https://tools.ietf.org/html/rfc2045]].
1038
+ # as defined in [MIME-IMB[https://www.rfc-editor.org/rfc/rfc2045]].
1213
1039
 
1214
1040
  ##
1215
1041
  # method: parts
@@ -1223,7 +1049,7 @@ module Net
1223
1049
  # call-seq: param -> hash
1224
1050
  #
1225
1051
  # Returns a hash that represents parameters
1226
- # as defined in [MIME-IMB[https://tools.ietf.org/html/rfc2045]].
1052
+ # as defined in [MIME-IMB[https://www.rfc-editor.org/rfc/rfc2045]].
1227
1053
 
1228
1054
  ##
1229
1055
  # method: disposition
@@ -1260,28 +1086,11 @@ module Net
1260
1086
  # generate a warning message to +stderr+, then return
1261
1087
  # the value of +subtype+.
1262
1088
  def media_subtype
1263
- warn("media_subtype is obsolete, use subtype instead.\n", uplevel: 1)
1089
+ warn("media_subtype is obsolete, use subtype instead.\n",
1090
+ uplevel: 1, category: :deprecated)
1264
1091
  return subtype
1265
1092
  end
1266
1093
  end
1267
1094
 
1268
- # === WARNING:
1269
- # >>>
1270
- # BodyTypeExtension is (incorrectly) used for <tt>message/*</tt> parts
1271
- # (besides <tt>message/rfc822</tt>, which correctly uses BodyTypeMessage).
1272
- #
1273
- # A future release will replace this class with:
1274
- # * BodyTypeMessage for <tt>message/rfc822</tt> and <tt>message/global</tt>
1275
- # * BodyTypeBasic for any other <tt>message/*</tt>
1276
- class BodyTypeExtension < Struct.new(:media_type, :subtype,
1277
- :params, :content_id,
1278
- :description, :encoding, :size)
1279
- include BodyStructure
1280
-
1281
- def multipart?
1282
- return false
1283
- end
1284
- end
1285
-
1286
1095
  end
1287
1096
  end