net-imap 0.4.12 → 0.5.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (51) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +8 -1
  3. data/README.md +10 -4
  4. data/docs/styles.css +75 -14
  5. data/lib/net/imap/authenticators.rb +2 -2
  6. data/lib/net/imap/command_data.rb +61 -48
  7. data/lib/net/imap/config/attr_accessors.rb +75 -0
  8. data/lib/net/imap/config/attr_inheritance.rb +90 -0
  9. data/lib/net/imap/config/attr_type_coercion.rb +61 -0
  10. data/lib/net/imap/config.rb +470 -0
  11. data/lib/net/imap/data_encoding.rb +3 -3
  12. data/lib/net/imap/data_lite.rb +226 -0
  13. data/lib/net/imap/deprecated_client_options.rb +8 -5
  14. data/lib/net/imap/errors.rb +6 -0
  15. data/lib/net/imap/esearch_result.rb +180 -0
  16. data/lib/net/imap/fetch_data.rb +126 -47
  17. data/lib/net/imap/response_data.rb +124 -237
  18. data/lib/net/imap/response_parser/parser_utils.rb +11 -6
  19. data/lib/net/imap/response_parser.rb +187 -34
  20. data/lib/net/imap/sasl/anonymous_authenticator.rb +3 -3
  21. data/lib/net/imap/sasl/authentication_exchange.rb +52 -20
  22. data/lib/net/imap/sasl/authenticators.rb +8 -4
  23. data/lib/net/imap/sasl/client_adapter.rb +77 -26
  24. data/lib/net/imap/sasl/cram_md5_authenticator.rb +4 -4
  25. data/lib/net/imap/sasl/digest_md5_authenticator.rb +218 -56
  26. data/lib/net/imap/sasl/external_authenticator.rb +2 -2
  27. data/lib/net/imap/sasl/gs2_header.rb +7 -7
  28. data/lib/net/imap/sasl/login_authenticator.rb +4 -3
  29. data/lib/net/imap/sasl/oauthbearer_authenticator.rb +6 -6
  30. data/lib/net/imap/sasl/plain_authenticator.rb +7 -7
  31. data/lib/net/imap/sasl/protocol_adapters.rb +60 -4
  32. data/lib/net/imap/sasl/scram_authenticator.rb +8 -8
  33. data/lib/net/imap/sasl.rb +7 -4
  34. data/lib/net/imap/sasl_adapter.rb +0 -1
  35. data/lib/net/imap/search_result.rb +2 -2
  36. data/lib/net/imap/sequence_set.rb +221 -82
  37. data/lib/net/imap/stringprep/nameprep.rb +1 -1
  38. data/lib/net/imap/stringprep/trace.rb +4 -4
  39. data/lib/net/imap/uidplus_data.rb +244 -0
  40. data/lib/net/imap/vanished_data.rb +56 -0
  41. data/lib/net/imap.rb +1010 -320
  42. data/net-imap.gemspec +3 -3
  43. data/rakelib/rfcs.rake +2 -0
  44. data/rakelib/string_prep_tables_generator.rb +2 -0
  45. metadata +12 -10
  46. data/.github/dependabot.yml +0 -6
  47. data/.github/workflows/pages.yml +0 -46
  48. data/.github/workflows/push_gem.yml +0 -48
  49. data/.github/workflows/test.yml +0 -31
  50. data/.gitignore +0 -12
  51. data/.mailmap +0 -13
@@ -2,9 +2,15 @@
2
2
 
3
3
  module Net
4
4
  class IMAP < Protocol
5
+ autoload :ESearchResult, "#{__dir__}/esearch_result"
5
6
  autoload :FetchData, "#{__dir__}/fetch_data"
7
+ autoload :UIDFetchData, "#{__dir__}/fetch_data"
6
8
  autoload :SearchResult, "#{__dir__}/search_result"
7
9
  autoload :SequenceSet, "#{__dir__}/sequence_set"
10
+ autoload :UIDPlusData, "#{__dir__}/uidplus_data"
11
+ autoload :AppendUIDData, "#{__dir__}/uidplus_data"
12
+ autoload :CopyUIDData, "#{__dir__}/uidplus_data"
13
+ autoload :VanishedData, "#{__dir__}/vanished_data"
8
14
 
9
15
  # Net::IMAP::ContinuationRequest represents command continuation requests.
10
16
  #
@@ -157,13 +163,20 @@ module Net
157
163
  # The raw response data.
158
164
  end
159
165
 
160
- # Net::IMAP::ResponseText represents texts of responses.
166
+ # ResponseText represents texts of responses.
161
167
  #
162
168
  # The text may be prefixed by a ResponseCode.
163
169
  #
164
- # ResponseText is returned from TaggedResponse#data, or from
165
- # UntaggedResponse#data when the response type is a "condition" ("OK", "NO",
166
- # "BAD", "PREAUTH", or "BYE").
170
+ # ResponseText is returned from TaggedResponse#data or
171
+ # UntaggedResponse#data for
172
+ # {"status responses"}[https://www.rfc-editor.org/rfc/rfc3501#section-7.1]:
173
+ # * every TaggedResponse, name[rdoc-ref:TaggedResponse#name] is always
174
+ # "+OK+", "+NO+", or "+BAD+".
175
+ # * any UntaggedResponse when name[rdoc-ref:UntaggedResponse#name] is
176
+ # "+OK+", "+NO+", "+BAD+", "+PREAUTH+", or "+BYE+".
177
+ #
178
+ # Note that these "status responses" are confusingly _not_ the same as the
179
+ # +STATUS+ UntaggedResponse (see IMAP#status and StatusData).
167
180
  class ResponseText < Struct.new(:code, :text)
168
181
  # Used to avoid an allocation when ResponseText is empty
169
182
  EMPTY = new(nil, "").freeze
@@ -181,32 +194,35 @@ module Net
181
194
  # Returns the response text, not including any response code
182
195
  end
183
196
 
184
- # Net::IMAP::ResponseCode represents response codes. Response codes can be
185
- # retrieved from ResponseText#code and can be included in any "condition"
186
- # response: any TaggedResponse and UntaggedResponse when the response type
187
- # is a "condition" ("OK", "NO", "BAD", "PREAUTH", or "BYE").
197
+ # ResponseCode represents an \IMAP response code, which can be retrieved
198
+ # from ResponseText#code for
199
+ # {"status responses"}[https://www.rfc-editor.org/rfc/rfc3501#section-7.1]:
200
+ # * every TaggedResponse, name[rdoc-ref:TaggedResponse#name] is always
201
+ # "+OK+", "+NO+", or "+BAD+".
202
+ # * any UntaggedResponse when name[rdoc-ref:UntaggedResponse#name] is
203
+ # "+OK+", "+NO+", "+BAD+", "+PREAUTH+", or "+BYE+".
204
+ #
205
+ # Note that these "status responses" are confusingly _not_ the same as the
206
+ # +STATUS+ UntaggedResponse (see IMAP#status and StatusData).
188
207
  #
189
208
  # Some response codes come with additional data which will be parsed by
190
209
  # Net::IMAP. Others return +nil+ for #data, but are used as a
191
210
  # machine-readable annotation for the human-readable ResponseText#text in
192
- # the same response. When Net::IMAP does not know how to parse response
193
- # code text, #data returns the unparsed string.
211
+ # the same response.
194
212
  #
195
213
  # Untagged response code #data is pushed directly onto Net::IMAP#responses,
196
214
  # keyed by #name, unless it is removed by the command that generated it.
197
215
  # Use Net::IMAP#add_response_handler to view tagged response codes for
198
216
  # command methods that do not return their TaggedResponse.
199
217
  #
218
+ # == Standard response codes
219
+ #
200
220
  # \IMAP extensions may define new codes and the data that comes with them.
201
221
  # The IANA {IMAP Response
202
222
  # Codes}[https://www.iana.org/assignments/imap-response-codes/imap-response-codes.xhtml]
203
223
  # registry has links to specifications for all standard response codes.
204
- # Response codes are backwards compatible: Servers are allowed to send new
205
- # response codes even if the client has not enabled the extension that
206
- # defines them. When unknown response code data is encountered, #data
207
- # will return an unparsed string.
208
224
  #
209
- # ==== +IMAP4rev1+ Response Codes
225
+ # === +IMAP4rev1+ response codes
210
226
  # See [IMAP4rev1[https://www.rfc-editor.org/rfc/rfc3501]] {§7.1, "Server
211
227
  # Responses - Status
212
228
  # Responses"}[https://www.rfc-editor.org/rfc/rfc3501#section-7.1] for full
@@ -237,24 +253,24 @@ module Net
237
253
  # the <tt>\Seen</tt> flag set.
238
254
  # <em>DEPRECATED by IMAP4rev2.</em>
239
255
  #
240
- # ==== +BINARY+ extension
256
+ # === +BINARY+ extension
241
257
  # See {[RFC3516]}[https://www.rfc-editor.org/rfc/rfc3516].
242
258
  # * +UNKNOWN-CTE+, with a tagged +NO+ response, when the server does not
243
259
  # known how to decode a CTE (content-transfer-encoding). #data is +nil+.
244
260
  # See IMAP#fetch.
245
261
  #
246
- # ==== +UIDPLUS+ extension
262
+ # === +UIDPLUS+ extension
247
263
  # See {[RFC4315 §3]}[https://www.rfc-editor.org/rfc/rfc4315#section-3].
248
264
  # * +APPENDUID+, #data is UIDPlusData. See IMAP#append.
249
265
  # * +COPYUID+, #data is UIDPlusData. See IMAP#copy.
250
266
  # * +UIDNOTSTICKY+, #data is +nil+. See IMAP#select.
251
267
  #
252
- # ==== +SEARCHRES+ extension
268
+ # === +SEARCHRES+ extension
253
269
  # See {[RFC5182]}[https://www.rfc-editor.org/rfc/rfc5182].
254
270
  # * +NOTSAVED+, with a tagged +NO+ response, when the search result variable
255
271
  # is not saved. #data is +nil+.
256
272
  #
257
- # ==== +RFC5530+ Response Codes
273
+ # === +RFC5530+ response codes
258
274
  # See {[RFC5530]}[https://www.rfc-editor.org/rfc/rfc5530], "IMAP Response
259
275
  # Codes" for the definition of the following response codes, which are all
260
276
  # machine-readable annotations for the human-readable ResponseText#text, and
@@ -277,22 +293,22 @@ module Net
277
293
  # * +ALREADYEXISTS+
278
294
  # * +NONEXISTENT+
279
295
  #
280
- # ==== +QRESYNC+ extension
296
+ # === +QRESYNC+ extension
281
297
  # See {[RFC7162]}[https://www.rfc-editor.org/rfc/rfc7162.html].
282
298
  # * +CLOSED+, returned when the currently selected mailbox is closed
283
299
  # implicitly by selecting or examining another mailbox. #data is +nil+.
284
300
  #
285
- # ==== +IMAP4rev2+ Response Codes
301
+ # === +IMAP4rev2+ response codes
286
302
  # See {[RFC9051]}[https://www.rfc-editor.org/rfc/rfc9051] {§7.1, "Server
287
303
  # Responses - Status
288
304
  # Responses"}[https://www.rfc-editor.org/rfc/rfc9051#section-7.1] for full
289
305
  # descriptions of IMAP4rev2 response codes. IMAP4rev2 includes all of the
290
- # response codes listed above (except "UNSEEN") and adds the following:
306
+ # response codes listed above (except "+UNSEEN+") and adds the following:
291
307
  # * +HASCHILDREN+, with a tagged +NO+ response, when a mailbox delete failed
292
308
  # because the server doesn't allow deletion of mailboxes with children.
293
309
  # #data is +nil+.
294
310
  #
295
- # ==== +CONDSTORE+ extension
311
+ # === +CONDSTORE+ extension
296
312
  # See {[RFC7162]}[https://www.rfc-editor.org/rfc/rfc7162.html].
297
313
  # * +NOMODSEQ+, when selecting a mailbox that does not support
298
314
  # mod-sequences. #data is +nil+. See IMAP#select.
@@ -302,10 +318,17 @@ module Net
302
318
  # since the +UNCHANGEDSINCE+ mod-sequence given to +STORE+ or <tt>UID
303
319
  # STORE</tt>.
304
320
  #
305
- # ==== +OBJECTID+ extension
321
+ # === +OBJECTID+ extension
306
322
  # See {[RFC8474]}[https://www.rfc-editor.org/rfc/rfc8474.html].
307
323
  # * +MAILBOXID+, #data is a string
308
324
  #
325
+ # == Extension compatibility
326
+ #
327
+ # Response codes are backwards compatible: Servers are allowed to send new
328
+ # response codes even if the client has not enabled the extension that
329
+ # defines them. When Net::IMAP does not know how to parse response
330
+ # code text, #data returns the unparsed string.
331
+ #
309
332
  class ResponseCode < Struct.new(:name, :data)
310
333
  ##
311
334
  # method: name
@@ -324,64 +347,8 @@ module Net
324
347
  # code data can take.
325
348
  end
326
349
 
327
- # Net::IMAP::UIDPlusData represents the ResponseCode#data that accompanies
328
- # the +APPENDUID+ and +COPYUID+ response codes.
329
- #
330
- # See [[UIDPLUS[https://www.rfc-editor.org/rfc/rfc4315.html]].
331
- #
332
- # ==== Capability requirement
333
- #
334
- # The +UIDPLUS+ capability[rdoc-ref:Net::IMAP#capability] must be supported.
335
- # A server that supports +UIDPLUS+ should send a UIDPlusData object inside
336
- # every TaggedResponse returned by the append[rdoc-ref:Net::IMAP#append],
337
- # copy[rdoc-ref:Net::IMAP#copy], move[rdoc-ref:Net::IMAP#move], {uid
338
- # copy}[rdoc-ref:Net::IMAP#uid_copy], and {uid
339
- # move}[rdoc-ref:Net::IMAP#uid_move] commands---unless the destination
340
- # mailbox reports +UIDNOTSTICKY+.
341
- #
342
- #--
343
- # TODO: support MULTIAPPEND
344
- #++
345
- #
346
- class UIDPlusData < Struct.new(:uidvalidity, :source_uids, :assigned_uids)
347
- ##
348
- # method: uidvalidity
349
- # :call-seq: uidvalidity -> nonzero uint32
350
- #
351
- # The UIDVALIDITY of the destination mailbox.
352
-
353
- ##
354
- # method: source_uids
355
- # :call-seq: source_uids -> nil or an array of nonzero uint32
356
- #
357
- # The UIDs of the copied or moved messages.
358
- #
359
- # Note:: Returns +nil+ for Net::IMAP#append.
360
-
361
- ##
362
- # method: assigned_uids
363
- # :call-seq: assigned_uids -> an array of nonzero uint32
364
- #
365
- # The newly assigned UIDs of the copied, moved, or appended messages.
366
- #
367
- # Note:: This always returns an array, even when it contains only one UID.
368
-
369
- ##
370
- # :call-seq: uid_mapping -> nil or a hash
371
- #
372
- # Returns a hash mapping each source UID to the newly assigned destination
373
- # UID.
374
- #
375
- # Note:: Returns +nil+ for Net::IMAP#append.
376
- def uid_mapping
377
- source_uids&.zip(assigned_uids)&.to_h
378
- end
379
- end
380
-
381
- # Net::IMAP::MailboxList represents contents of the LIST response,
382
- # representing a single mailbox path.
383
- #
384
- # Net::IMAP#list returns an array of MailboxList objects.
350
+ # MailboxList represents the data of an untagged +LIST+ response, for a
351
+ # _single_ mailbox path. IMAP#list returns an array of MailboxList objects.
385
352
  #
386
353
  class MailboxList < Struct.new(:attr, :delim, :name)
387
354
  ##
@@ -391,11 +358,11 @@ module Net
391
358
  # Returns the name attributes. Each name attribute is a symbol capitalized
392
359
  # by String#capitalize, such as :Noselect (not :NoSelect). For the
393
360
  # semantics of each attribute, see:
394
- # * rdoc-ref:Net::IMAP@Basic+Mailbox+Attributes
395
- # * rdoc-ref:Net::IMAP@Mailbox+role+Attributes
396
- # * Net::IMAP@SPECIAL-USE
361
+ # * Net::IMAP@Basic+Mailbox+Attributes
362
+ # * Net::IMAP@Mailbox+role+Attributes
397
363
  # * The IANA {IMAP Mailbox Name Attributes
398
364
  # registry}[https://www.iana.org/assignments/imap-mailbox-name-attributes/imap-mailbox-name-attributes.xhtml]
365
+ # has links to specifications for all standard mailbox attributes.
399
366
 
400
367
  ##
401
368
  # method: delim
@@ -410,16 +377,16 @@ module Net
410
377
  # Returns the mailbox name.
411
378
  end
412
379
 
413
- # Net::IMAP::MailboxQuota represents contents of GETQUOTA response.
414
- # This object can also be a response to GETQUOTAROOT. In the syntax
415
- # specification below, the delimiter used with the "#" construct is a
416
- # single space (SPACE).
380
+ # MailboxQuota represents the data of an untagged +QUOTA+ response.
417
381
  #
418
- # Net:IMAP#getquota returns an array of MailboxQuota objects.
382
+ # IMAP#getquota returns an array of MailboxQuota objects.
419
383
  #
420
384
  # Net::IMAP#getquotaroot returns an array containing both MailboxQuotaRoot
421
385
  # and MailboxQuota objects.
422
386
  #
387
+ # == Required capability
388
+ # Requires +QUOTA+ [RFC2087[https://www.rfc-editor.org/rfc/rfc2087]]
389
+ # capability.
423
390
  class MailboxQuota < Struct.new(:mailbox, :usage, :quota)
424
391
  ##
425
392
  # method: mailbox
@@ -441,12 +408,14 @@ module Net
441
408
  #
442
409
  end
443
410
 
444
- # Net::IMAP::MailboxQuotaRoot represents part of the GETQUOTAROOT
445
- # response. (GETQUOTAROOT can also return Net::IMAP::MailboxQuota.)
411
+ # MailboxQuotaRoot represents the data of an untagged +QUOTAROOT+ response.
446
412
  #
447
- # Net::IMAP#getquotaroot returns an array containing both MailboxQuotaRoot
448
- # and MailboxQuota objects.
413
+ # IMAP#getquotaroot returns an array containing both MailboxQuotaRoot and
414
+ # MailboxQuota objects.
449
415
  #
416
+ # == Required capability
417
+ # Requires +QUOTA+ [RFC2087[https://www.rfc-editor.org/rfc/rfc2087]]
418
+ # capability.
450
419
  class MailboxQuotaRoot < Struct.new(:mailbox, :quotaroots)
451
420
  ##
452
421
  # method: mailbox
@@ -461,12 +430,13 @@ module Net
461
430
  # Zero or more quotaroots that affect the quota on the specified mailbox.
462
431
  end
463
432
 
464
- # Net::IMAP::MailboxACLItem represents the response from GETACL.
433
+ # MailboxACLItem represents the data of an untagged +ACL+ response.
465
434
  #
466
- # Net::IMAP#getacl returns an array of MailboxACLItem objects.
435
+ # IMAP#getacl returns an array of MailboxACLItem objects.
467
436
  #
468
- # ==== Required capability
469
- # +ACL+ - described in [ACL[https://tools.ietf.org/html/rfc4314]]
437
+ # == Required capability
438
+ # Requires +ACL+ [RFC4314[https://www.rfc-editor.org/rfc/rfc4314]]
439
+ # capability.
470
440
  class MailboxACLItem < Struct.new(:user, :rights, :mailbox)
471
441
  ##
472
442
  # method: mailbox
@@ -488,11 +458,12 @@ module Net
488
458
  # The access rights the indicated #user has to the #mailbox.
489
459
  end
490
460
 
491
- # Net::IMAP::Namespace represents a single namespace contained inside a
492
- # NAMESPACE response.
493
- #
494
- # Returned by Net::IMAP#namespace, contained inside a Namespaces object.
461
+ # Namespace represents a _single_ namespace, contained inside a Namespaces
462
+ # object.
495
463
  #
464
+ # == Required capability
465
+ # Requires either +NAMESPACE+ [RFC2342[https://www.rfc-editor.org/rfc/rfc2342]]
466
+ # or +IMAP4rev2+ capability.
496
467
  class Namespace < Struct.new(:prefix, :delim, :extensions)
497
468
  ##
498
469
  # method: prefix
@@ -514,11 +485,14 @@ module Net
514
485
  # Extension parameter semantics would be defined by the extension.
515
486
  end
516
487
 
517
- # Net::IMAP::Namespaces represents a +NAMESPACE+ server response, which
518
- # contains lists of #personal, #shared, and #other namespaces.
488
+ # Namespaces represents the data of an untagged +NAMESPACE+ response,
489
+ # returned by IMAP#namespace.
519
490
  #
520
- # Net::IMAP#namespace returns a Namespaces object.
491
+ # Contains lists of #personal, #shared, and #other namespaces.
521
492
  #
493
+ # == Required capability
494
+ # Requires either +NAMESPACE+ [RFC2342[https://www.rfc-editor.org/rfc/rfc2342]]
495
+ # or +IMAP4rev2+ capability.
522
496
  class Namespaces < Struct.new(:personal, :other, :shared)
523
497
  ##
524
498
  # method: personal
@@ -539,9 +513,9 @@ module Net
539
513
  # Returns an array of Shared Namespace objects.
540
514
  end
541
515
 
542
- # Net::IMAP::StatusData represents the contents of the STATUS response.
516
+ # StatusData represents the contents of an untagged +STATUS+ response.
543
517
  #
544
- # Net::IMAP#status returns the contents of #attr.
518
+ # IMAP#status returns the contents of #attr.
545
519
  class StatusData < Struct.new(:mailbox, :attr)
546
520
  ##
547
521
  # method: mailbox
@@ -562,11 +536,11 @@ module Net
562
536
  # [Note]
563
537
  # When the #sender and #reply_to fields are absent or empty, they will
564
538
  # return the same value as #from. Also, fields may return values that are
565
- # invalid for well-formed [RFC5322[https://tools.ietf.org/html/rfc5322]]
539
+ # invalid for well-formed [RFC5322[https://www.rfc-editor.org/rfc/rfc5322]]
566
540
  # messages when the message is malformed or a draft message.
567
541
  #
568
- # See [{IMAP4rev1 §7.4.2}[https://www.rfc-editor.org/rfc/rfc3501.html#section-7.4.2]]
569
- # and [{IMAP4rev2 §7.5.2}[https://www.rfc-editor.org/rfc/rfc9051.html#section-7.5.2]]
542
+ # See [{IMAP4rev1 §7.4.2}[https://www.rfc-editor.org/rfc/rfc3501#section-7.4.2]]
543
+ # and [{IMAP4rev2 §7.5.2}[https://www.rfc-editor.org/rfc/rfc9051#section-7.5.2]]
570
544
  # for full description of the envelope fields, and
571
545
  # Net::IMAP@Message+envelope+and+body+structure for other relevant RFCs.
572
546
  #
@@ -580,7 +554,7 @@ module Net
580
554
  # Returns a string that represents the +Date+ header.
581
555
  #
582
556
  # [Note]
583
- # For a well-formed [RFC5322[https://tools.ietf.org/html/rfc5322]]
557
+ # For a well-formed [RFC5322[https://www.rfc-editor.org/rfc/rfc5322]]
584
558
  # message, the #date field must not be +nil+. However it can be +nil+
585
559
  # for a malformed or draft message.
586
560
 
@@ -606,7 +580,7 @@ module Net
606
580
  # returns +nil+ for this envelope field.
607
581
  #
608
582
  # [Note]
609
- # For a well-formed [RFC5322[https://tools.ietf.org/html/rfc5322]]
583
+ # For a well-formed [RFC5322[https://www.rfc-editor.org/rfc/rfc5322]]
610
584
  # message, the #from field must not be +nil+. However it can be +nil+
611
585
  # for a malformed or draft message.
612
586
 
@@ -619,7 +593,7 @@ module Net
619
593
  # [Note]
620
594
  # If the <tt>Sender</tt> header is absent, or is present but empty, the
621
595
  # server sets this field to be the same value as #from. Therefore, in a
622
- # well-formed [RFC5322[https://tools.ietf.org/html/rfc5322]] message,
596
+ # well-formed [RFC5322[https://www.rfc-editor.org/rfc/rfc5322]] message,
623
597
  # the #sender envelope field must not be +nil+. However it can be
624
598
  # +nil+ for a malformed or draft message.
625
599
 
@@ -633,7 +607,7 @@ module Net
633
607
  # [Note]
634
608
  # If the <tt>Reply-To</tt> header is absent, or is present but empty,
635
609
  # the server sets this field to be the same value as #from. Therefore,
636
- # in a well-formed [RFC5322[https://tools.ietf.org/html/rfc5322]]
610
+ # in a well-formed [RFC5322[https://www.rfc-editor.org/rfc/rfc5322]]
637
611
  # message, the #reply_to envelope field must not be +nil+. However it
638
612
  # can be +nil+ for a malformed or draft message.
639
613
 
@@ -662,7 +636,7 @@ module Net
662
636
  # Returns a string that represents the <tt>In-Reply-To</tt> header.
663
637
  #
664
638
  # [Note]
665
- # For a well-formed [RFC5322[https://tools.ietf.org/html/rfc5322]]
639
+ # For a well-formed [RFC5322[https://www.rfc-editor.org/rfc/rfc5322]]
666
640
  # message, the #in_reply_to field, if present, must not be empty. But
667
641
  # it can still return an empty string for malformed messages.
668
642
  #
@@ -678,7 +652,7 @@ module Net
678
652
  # Returns a string that represents the <tt>Message-ID</tt>.
679
653
  #
680
654
  # [Note]
681
- # For a well-formed [RFC5322[https://tools.ietf.org/html/rfc5322]]
655
+ # For a well-formed [RFC5322[https://www.rfc-editor.org/rfc/rfc5322]]
682
656
  # message, the #message_id field, if present, must not be empty. But it
683
657
  # can still return an empty string for malformed messages.
684
658
  #
@@ -692,10 +666,10 @@ module Net
692
666
  # parsed into its component parts by the server. Address objects are
693
667
  # returned within Envelope fields.
694
668
  #
695
- # === Group syntax
669
+ # == Group syntax
696
670
  #
697
671
  # When the #host field is +nil+, this is a special form of address structure
698
- # that indicates the [RFC5322[https://tools.ietf.org/html/rfc5322]] group
672
+ # that indicates the [RFC5322[https://www.rfc-editor.org/rfc/rfc5322]] group
699
673
  # syntax. If the #mailbox name field is also +nil+, this is an end-of-group
700
674
  # marker (semicolon in RFC-822 syntax). If the #mailbox name field is
701
675
  # non-+NIL+, this is the start of a group marker, and the mailbox #name
@@ -705,7 +679,7 @@ module Net
705
679
  # method: name
706
680
  # :call-seq: name -> string or nil
707
681
  #
708
- # Returns the [RFC5322[https://tools.ietf.org/html/rfc5322]] address
682
+ # Returns the [RFC5322[https://www.rfc-editor.org/rfc/rfc5322]] address
709
683
  # +display-name+ (or the mailbox +phrase+ in the RFC-822 grammar).
710
684
 
711
685
  ##
@@ -715,28 +689,28 @@ module Net
715
689
  # Returns the route from RFC-822 route-addr.
716
690
  #
717
691
  # Note:: Generating this obsolete route addressing syntax is not allowed
718
- # by [RFC5322[https://tools.ietf.org/html/rfc5322]]. However,
692
+ # by [RFC5322[https://www.rfc-editor.org/rfc/rfc5322]]. However,
719
693
  # addresses with this syntax must still be accepted and parsed.
720
694
 
721
695
  ##
722
696
  # method: mailbox
723
697
  # :call-seq: mailbox -> string or nil
724
698
  #
725
- # Returns the [RFC5322[https://tools.ietf.org/html/rfc5322]] address
699
+ # Returns the [RFC5322[https://www.rfc-editor.org/rfc/rfc5322]] address
726
700
  # +local-part+, if #host is not +nil+.
727
701
  #
728
702
  # When #host is +nil+, this returns
729
- # an [RFC5322[https://tools.ietf.org/html/rfc5322]] group name and a +nil+
703
+ # an [RFC5322[https://www.rfc-editor.org/rfc/rfc5322]] group name and a +nil+
730
704
  # mailbox indicates the end of a group.
731
705
 
732
706
  ##
733
707
  # method: host
734
708
  # :call-seq: host -> string or nil
735
709
  #
736
- # Returns the [RFC5322[https://tools.ietf.org/html/rfc5322]] addr-spec
710
+ # Returns the [RFC5322[https://www.rfc-editor.org/rfc/rfc5322]] addr-spec
737
711
  # +domain+ name.
738
712
  #
739
- # +nil+ indicates [RFC5322[https://tools.ietf.org/html/rfc5322]] group
713
+ # +nil+ indicates [RFC5322[https://www.rfc-editor.org/rfc/rfc5322]] group
740
714
  # syntax.
741
715
  end
742
716
 
@@ -748,14 +722,14 @@ module Net
748
722
  # :call-seq: dsp_type -> string
749
723
  #
750
724
  # Returns the content disposition type, as defined by
751
- # [DISPOSITION[https://tools.ietf.org/html/rfc2183]].
725
+ # [DISPOSITION[https://www.rfc-editor.org/rfc/rfc2183]].
752
726
 
753
727
  ##
754
728
  # method: param
755
729
  # :call-seq: param -> hash
756
730
  #
757
731
  # Returns a hash representing parameters of the Content-Disposition
758
- # field, as defined by [DISPOSITION[https://tools.ietf.org/html/rfc2183]].
732
+ # field, as defined by [DISPOSITION[https://www.rfc-editor.org/rfc/rfc2183]].
759
733
  end
760
734
 
761
735
  # Net::IMAP::ThreadMember represents a thread-node returned
@@ -794,12 +768,12 @@ module Net
794
768
  # FetchData#attr value. Although these classes don't share a base class,
795
769
  # this module can be used to pattern match all of them.
796
770
  #
797
- # See {[IMAP4rev1] §7.4.2}[https://www.rfc-editor.org/rfc/rfc3501.html#section-7.4.2]
798
- # and {[IMAP4rev2] §7.5.2}[https://www.rfc-editor.org/rfc/rfc9051.html#section-7.5.2-4.9]
771
+ # See {[IMAP4rev1] §7.4.2}[https://www.rfc-editor.org/rfc/rfc3501#section-7.4.2]
772
+ # and {[IMAP4rev2] §7.5.2}[https://www.rfc-editor.org/rfc/rfc9051#section-7.5.2-4.9]
799
773
  # for full description of all +BODYSTRUCTURE+ fields, and also
800
774
  # Net::IMAP@Message+envelope+and+body+structure for other relevant RFCs.
801
775
  #
802
- # === Classes that include BodyStructure
776
+ # == Classes that include BodyStructure
803
777
  # BodyTypeBasic:: Represents any message parts that are not handled by
804
778
  # BodyTypeText, BodyTypeMessage, or BodyTypeMultipart.
805
779
  # BodyTypeText:: Used by <tt>text/*</tt> parts. Contains all of the
@@ -817,8 +791,8 @@ module Net
817
791
  # message parts, unless they have a <tt>Content-Type</tt> that is handled by
818
792
  # BodyTypeText, BodyTypeMessage, or BodyTypeMultipart.
819
793
  #
820
- # See {[IMAP4rev1] §7.4.2}[https://www.rfc-editor.org/rfc/rfc3501.html#section-7.4.2]
821
- # and {[IMAP4rev2] §7.5.2}[https://www.rfc-editor.org/rfc/rfc9051.html#section-7.5.2-4.9]
794
+ # See {[IMAP4rev1] §7.4.2}[https://www.rfc-editor.org/rfc/rfc3501#section-7.4.2]
795
+ # and {[IMAP4rev2] §7.5.2}[https://www.rfc-editor.org/rfc/rfc9051#section-7.5.2-4.9]
822
796
  # for full description of all +BODYSTRUCTURE+ fields, and also
823
797
  # Net::IMAP@Message+envelope+and+body+structure for other relevant RFCs.
824
798
  #
@@ -835,45 +809,45 @@ module Net
835
809
  # :call-seq: media_type -> string
836
810
  #
837
811
  # The top-level media type as defined in
838
- # [MIME-IMB[https://tools.ietf.org/html/rfc2045]].
812
+ # [MIME-IMB[https://www.rfc-editor.org/rfc/rfc2045]].
839
813
 
840
814
  ##
841
815
  # method: subtype
842
816
  # :call-seq: subtype -> string
843
817
  #
844
818
  # The media subtype name as defined in
845
- # [MIME-IMB[https://tools.ietf.org/html/rfc2045]].
819
+ # [MIME-IMB[https://www.rfc-editor.org/rfc/rfc2045]].
846
820
 
847
821
  ##
848
822
  # method: param
849
823
  # :call-seq: param -> string
850
824
  #
851
825
  # Returns a hash that represents parameters as defined in
852
- # [MIME-IMB[https://tools.ietf.org/html/rfc2045]].
826
+ # [MIME-IMB[https://www.rfc-editor.org/rfc/rfc2045]].
853
827
 
854
828
  ##
855
829
  # method: content_id
856
830
  # :call-seq: content_id -> string
857
831
  #
858
832
  # Returns a string giving the content id as defined
859
- # in [MIME-IMB[https://tools.ietf.org/html/rfc2045]]
860
- # {§7}[https://tools.ietf.org/html/rfc2045#section-7].
833
+ # in [MIME-IMB[https://www.rfc-editor.org/rfc/rfc2045]]
834
+ # {§7}[https://www.rfc-editor.org/rfc/rfc2045#section-7].
861
835
 
862
836
  ##
863
837
  # method: description
864
838
  # :call-seq: description -> string
865
839
  #
866
840
  # Returns a string giving the content description as defined
867
- # in [MIME-IMB[https://tools.ietf.org/html/rfc2045]]
868
- # {§8}[https://tools.ietf.org/html/rfc2045#section-8].
841
+ # in [MIME-IMB[https://www.rfc-editor.org/rfc/rfc2045]]
842
+ # {§8}[https://www.rfc-editor.org/rfc/rfc2045#section-8].
869
843
 
870
844
  ##
871
845
  # method: encoding
872
846
  # :call-seq: encoding -> string
873
847
  #
874
848
  # Returns a string giving the content transfer encoding as defined
875
- # in [MIME-IMB[https://tools.ietf.org/html/rfc2045]]
876
- # {§6}[https://tools.ietf.org/html/rfc2045#section-6].
849
+ # in [MIME-IMB[https://www.rfc-editor.org/rfc/rfc2045]]
850
+ # {§6}[https://www.rfc-editor.org/rfc/rfc2045#section-6].
877
851
 
878
852
  ##
879
853
  # method: size
@@ -886,7 +860,7 @@ module Net
886
860
  # :call-seq: md5 -> string
887
861
  #
888
862
  # Returns a string giving the body MD5 value as defined in
889
- # [MD5[https://tools.ietf.org/html/rfc1864]].
863
+ # [MD5[https://www.rfc-editor.org/rfc/rfc1864]].
890
864
 
891
865
  ##
892
866
  # method: disposition
@@ -894,7 +868,7 @@ module Net
894
868
  #
895
869
  # Returns a ContentDisposition object giving the content
896
870
  # disposition, as defined by
897
- # [DISPOSITION[https://tools.ietf.org/html/rfc2183]].
871
+ # [DISPOSITION[https://www.rfc-editor.org/rfc/rfc2183]].
898
872
 
899
873
  ##
900
874
  # method: language
@@ -939,7 +913,8 @@ module Net
939
913
  # for something else?
940
914
  #++
941
915
  def media_subtype
942
- warn("media_subtype is obsolete, use subtype instead.\n", uplevel: 1)
916
+ warn("media_subtype is obsolete, use subtype instead.\n",
917
+ uplevel: 1, category: :deprecated)
943
918
  return subtype
944
919
  end
945
920
  end
@@ -984,7 +959,8 @@ module Net
984
959
  # generate a warning message to +stderr+, then return
985
960
  # the value of +subtype+.
986
961
  def media_subtype
987
- warn("media_subtype is obsolete, use subtype instead.\n", uplevel: 1)
962
+ warn("media_subtype is obsolete, use subtype instead.\n",
963
+ uplevel: 1, category: :deprecated)
988
964
  return subtype
989
965
  end
990
966
  end
@@ -1040,77 +1016,6 @@ module Net
1040
1016
  end
1041
1017
  end
1042
1018
 
1043
- # BodyTypeAttachment is not used and will be removed in an upcoming release.
1044
- #
1045
- # === Bug Analysis
1046
- #
1047
- # \IMAP body structures are parenthesized lists and assign their fields
1048
- # positionally, so missing fields change the interpretation of all
1049
- # following fields. Additionally, different body types have a different
1050
- # number of required fields, followed by optional "extension" fields.
1051
- #
1052
- # BodyTypeAttachment was previously returned when a "message/rfc822" part,
1053
- # which should be sent as <tt>body-type-msg</tt> with ten required fields,
1054
- # was actually sent as a <tt>body-type-basic</tt> with _seven_ required
1055
- # fields.
1056
- #
1057
- # basic => type, subtype, param, id, desc, enc, octets, md5=nil, dsp=nil, lang=nil, loc=nil, *ext
1058
- # msg => type, subtype, param, id, desc, enc, octets, envelope, body, lines, md5=nil, ...
1059
- #
1060
- # Normally, +envelope+ and +md5+ are incompatible, but Net::IMAP leniently
1061
- # allowed buggy servers to send +NIL+ for +envelope+. As a result, when a
1062
- # server sent a <tt>message/rfc822</tt> part with +NIL+ for +md5+ and a
1063
- # non-<tt>NIL</tt> +dsp+, Net::IMAP misinterpreted the
1064
- # <tt>Content-Disposition</tt> as if it were a strange body type. In all
1065
- # reported cases, the <tt>Content-Disposition</tt> was "attachment", so
1066
- # BodyTypeAttachment was created as the workaround.
1067
- #
1068
- # === Current behavior
1069
- #
1070
- # When interpreted strictly, +envelope+ and +md5+ are incompatible. So the
1071
- # current parsing algorithm peeks ahead after it has received the seventh
1072
- # body field. If the next token is not the start of an +envelope+, we assume
1073
- # the server has incorrectly sent us a <tt>body-type-basic</tt> and return
1074
- # BodyTypeBasic. As a result, what was previously BodyTypeMessage#body =>
1075
- # BodyTypeAttachment is now BodyTypeBasic#disposition => ContentDisposition.
1076
- #
1077
- class BodyTypeAttachment < Struct.new(:dsp_type, :_unused_, :param)
1078
- # *invalid for BodyTypeAttachment*
1079
- def media_type
1080
- warn(<<~WARN, uplevel: 1)
1081
- BodyTypeAttachment#media_type is obsolete. Use dsp_type instead.
1082
- WARN
1083
- dsp_type
1084
- end
1085
-
1086
- # *invalid for BodyTypeAttachment*
1087
- def subtype
1088
- warn("BodyTypeAttachment#subtype is obsolete.\n", uplevel: 1)
1089
- nil
1090
- end
1091
-
1092
- ##
1093
- # method: dsp_type
1094
- # :call-seq: dsp_type -> string
1095
- #
1096
- # Returns the content disposition type, as defined by
1097
- # [DISPOSITION[https://tools.ietf.org/html/rfc2183]].
1098
-
1099
- ##
1100
- # method: param
1101
- # :call-seq: param -> hash
1102
- #
1103
- # Returns a hash representing parameters of the Content-Disposition
1104
- # field, as defined by [DISPOSITION[https://tools.ietf.org/html/rfc2183]].
1105
-
1106
- ##
1107
- def multipart?
1108
- return false
1109
- end
1110
- end
1111
-
1112
- deprecate_constant :BodyTypeAttachment
1113
-
1114
1019
  # Net::IMAP::BodyTypeMultipart represents body structures of messages and
1115
1020
  # message parts, when <tt>Content-Type</tt> is <tt>multipart/*</tt>.
1116
1021
  class BodyTypeMultipart < Struct.new(:media_type, :subtype,
@@ -1131,7 +1036,7 @@ module Net
1131
1036
  # call-seq: subtype -> string
1132
1037
  #
1133
1038
  # Returns the content subtype name
1134
- # as defined in [MIME-IMB[https://tools.ietf.org/html/rfc2045]].
1039
+ # as defined in [MIME-IMB[https://www.rfc-editor.org/rfc/rfc2045]].
1135
1040
 
1136
1041
  ##
1137
1042
  # method: parts
@@ -1145,7 +1050,7 @@ module Net
1145
1050
  # call-seq: param -> hash
1146
1051
  #
1147
1052
  # Returns a hash that represents parameters
1148
- # as defined in [MIME-IMB[https://tools.ietf.org/html/rfc2045]].
1053
+ # as defined in [MIME-IMB[https://www.rfc-editor.org/rfc/rfc2045]].
1149
1054
 
1150
1055
  ##
1151
1056
  # method: disposition
@@ -1182,29 +1087,11 @@ module Net
1182
1087
  # generate a warning message to +stderr+, then return
1183
1088
  # the value of +subtype+.
1184
1089
  def media_subtype
1185
- warn("media_subtype is obsolete, use subtype instead.\n", uplevel: 1)
1090
+ warn("media_subtype is obsolete, use subtype instead.\n",
1091
+ uplevel: 1, category: :deprecated)
1186
1092
  return subtype
1187
1093
  end
1188
1094
  end
1189
1095
 
1190
- # === Obsolete
1191
- # BodyTypeExtension is not used and will be removed in an upcoming release.
1192
- #
1193
- # >>>
1194
- # BodyTypeExtension was (incorrectly) used for <tt>message/*</tt> parts
1195
- # (besides <tt>message/rfc822</tt>, which correctly uses BodyTypeMessage).
1196
- #
1197
- # Net::IMAP now (correctly) parses all message types (other than
1198
- # <tt>message/rfc822</tt> or <tt>message/global</tt>) as BodyTypeBasic.
1199
- class BodyTypeExtension < Struct.new(:media_type, :subtype,
1200
- :params, :content_id,
1201
- :description, :encoding, :size)
1202
- def multipart?
1203
- return false
1204
- end
1205
- end
1206
-
1207
- deprecate_constant :BodyTypeExtension
1208
-
1209
1096
  end
1210
1097
  end