net-imap 0.4.22 → 0.6.3
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.
- checksums.yaml +4 -4
- data/Gemfile +12 -2
- data/README.md +10 -4
- data/docs/styles.css +75 -14
- data/lib/net/imap/authenticators.rb +2 -2
- data/lib/net/imap/command_data.rb +40 -95
- data/lib/net/imap/config/attr_accessors.rb +8 -9
- data/lib/net/imap/config/attr_inheritance.rb +64 -1
- data/lib/net/imap/config/attr_type_coercion.rb +22 -10
- data/lib/net/imap/config/attr_version_defaults.rb +90 -0
- data/lib/net/imap/config.rb +241 -125
- data/lib/net/imap/connection_state.rb +48 -0
- data/lib/net/imap/data_encoding.rb +80 -31
- data/lib/net/imap/deprecated_client_options.rb +6 -3
- data/lib/net/imap/errors.rb +158 -0
- data/lib/net/imap/esearch_result.rb +225 -0
- data/lib/net/imap/fetch_data.rb +126 -47
- data/lib/net/imap/flags.rb +1 -1
- data/lib/net/imap/response_data.rb +123 -187
- data/lib/net/imap/response_parser/parser_utils.rb +19 -23
- data/lib/net/imap/response_parser.rb +182 -38
- data/lib/net/imap/response_reader.rb +10 -12
- data/lib/net/imap/sasl/anonymous_authenticator.rb +3 -3
- data/lib/net/imap/sasl/authentication_exchange.rb +52 -20
- data/lib/net/imap/sasl/authenticators.rb +8 -4
- data/lib/net/imap/sasl/client_adapter.rb +77 -26
- data/lib/net/imap/sasl/cram_md5_authenticator.rb +4 -4
- data/lib/net/imap/sasl/digest_md5_authenticator.rb +218 -56
- data/lib/net/imap/sasl/external_authenticator.rb +2 -2
- data/lib/net/imap/sasl/gs2_header.rb +7 -7
- data/lib/net/imap/sasl/login_authenticator.rb +4 -3
- data/lib/net/imap/sasl/oauthbearer_authenticator.rb +6 -6
- data/lib/net/imap/sasl/plain_authenticator.rb +7 -7
- data/lib/net/imap/sasl/protocol_adapters.rb +60 -4
- data/lib/net/imap/sasl/scram_authenticator.rb +8 -8
- data/lib/net/imap/sasl.rb +7 -4
- data/lib/net/imap/sasl_adapter.rb +0 -1
- data/lib/net/imap/search_result.rb +10 -5
- data/lib/net/imap/sequence_set.rb +1104 -421
- data/lib/net/imap/stringprep/nameprep.rb +1 -1
- data/lib/net/imap/stringprep/trace.rb +4 -4
- data/lib/net/imap/uidplus_data.rb +4 -147
- data/lib/net/imap/vanished_data.rb +65 -0
- data/lib/net/imap.rb +1002 -313
- data/net-imap.gemspec +1 -1
- data/rakelib/rfcs.rake +2 -0
- data/rakelib/string_prep_tables_generator.rb +6 -2
- metadata +7 -3
|
@@ -2,12 +2,13 @@
|
|
|
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
|
-
autoload :SequenceSet, "#{__dir__}/sequence_set"
|
|
8
|
-
autoload :UIDPlusData, "#{__dir__}/uidplus_data"
|
|
9
9
|
autoload :AppendUIDData, "#{__dir__}/uidplus_data"
|
|
10
10
|
autoload :CopyUIDData, "#{__dir__}/uidplus_data"
|
|
11
|
+
autoload :VanishedData, "#{__dir__}/vanished_data"
|
|
11
12
|
|
|
12
13
|
# Net::IMAP::ContinuationRequest represents command continuation requests.
|
|
13
14
|
#
|
|
@@ -160,13 +161,20 @@ module Net
|
|
|
160
161
|
# The raw response data.
|
|
161
162
|
end
|
|
162
163
|
|
|
163
|
-
#
|
|
164
|
+
# ResponseText represents texts of responses.
|
|
164
165
|
#
|
|
165
166
|
# The text may be prefixed by a ResponseCode.
|
|
166
167
|
#
|
|
167
|
-
# ResponseText is returned from TaggedResponse#data
|
|
168
|
-
# UntaggedResponse#data
|
|
169
|
-
# "
|
|
168
|
+
# ResponseText is returned from TaggedResponse#data or
|
|
169
|
+
# UntaggedResponse#data for
|
|
170
|
+
# {"status responses"}[https://www.rfc-editor.org/rfc/rfc3501#section-7.1]:
|
|
171
|
+
# * every TaggedResponse, name[rdoc-ref:TaggedResponse#name] is always
|
|
172
|
+
# "+OK+", "+NO+", or "+BAD+".
|
|
173
|
+
# * any UntaggedResponse when name[rdoc-ref:UntaggedResponse#name] is
|
|
174
|
+
# "+OK+", "+NO+", "+BAD+", "+PREAUTH+", or "+BYE+".
|
|
175
|
+
#
|
|
176
|
+
# Note that these "status responses" are confusingly _not_ the same as the
|
|
177
|
+
# +STATUS+ UntaggedResponse (see IMAP#status and StatusData).
|
|
170
178
|
class ResponseText < Struct.new(:code, :text)
|
|
171
179
|
# Used to avoid an allocation when ResponseText is empty
|
|
172
180
|
EMPTY = new(nil, "").freeze
|
|
@@ -184,32 +192,35 @@ module Net
|
|
|
184
192
|
# Returns the response text, not including any response code
|
|
185
193
|
end
|
|
186
194
|
|
|
187
|
-
#
|
|
188
|
-
#
|
|
189
|
-
#
|
|
190
|
-
#
|
|
195
|
+
# ResponseCode represents an \IMAP response code, which can be retrieved
|
|
196
|
+
# from ResponseText#code for
|
|
197
|
+
# {"status responses"}[https://www.rfc-editor.org/rfc/rfc3501#section-7.1]:
|
|
198
|
+
# * every TaggedResponse, name[rdoc-ref:TaggedResponse#name] is always
|
|
199
|
+
# "+OK+", "+NO+", or "+BAD+".
|
|
200
|
+
# * any UntaggedResponse when name[rdoc-ref:UntaggedResponse#name] is
|
|
201
|
+
# "+OK+", "+NO+", "+BAD+", "+PREAUTH+", or "+BYE+".
|
|
202
|
+
#
|
|
203
|
+
# Note that these "status responses" are confusingly _not_ the same as the
|
|
204
|
+
# +STATUS+ UntaggedResponse (see IMAP#status and StatusData).
|
|
191
205
|
#
|
|
192
206
|
# Some response codes come with additional data which will be parsed by
|
|
193
207
|
# Net::IMAP. Others return +nil+ for #data, but are used as a
|
|
194
208
|
# machine-readable annotation for the human-readable ResponseText#text in
|
|
195
|
-
# the same response.
|
|
196
|
-
# code text, #data returns the unparsed string.
|
|
209
|
+
# the same response.
|
|
197
210
|
#
|
|
198
211
|
# Untagged response code #data is pushed directly onto Net::IMAP#responses,
|
|
199
212
|
# keyed by #name, unless it is removed by the command that generated it.
|
|
200
213
|
# Use Net::IMAP#add_response_handler to view tagged response codes for
|
|
201
214
|
# command methods that do not return their TaggedResponse.
|
|
202
215
|
#
|
|
216
|
+
# == Standard response codes
|
|
217
|
+
#
|
|
203
218
|
# \IMAP extensions may define new codes and the data that comes with them.
|
|
204
219
|
# The IANA {IMAP Response
|
|
205
220
|
# Codes}[https://www.iana.org/assignments/imap-response-codes/imap-response-codes.xhtml]
|
|
206
221
|
# registry has links to specifications for all standard response codes.
|
|
207
|
-
# Response codes are backwards compatible: Servers are allowed to send new
|
|
208
|
-
# response codes even if the client has not enabled the extension that
|
|
209
|
-
# defines them. When unknown response code data is encountered, #data
|
|
210
|
-
# will return an unparsed string.
|
|
211
222
|
#
|
|
212
|
-
#
|
|
223
|
+
# === +IMAP4rev1+ response codes
|
|
213
224
|
# See [IMAP4rev1[https://www.rfc-editor.org/rfc/rfc3501]] {§7.1, "Server
|
|
214
225
|
# Responses - Status
|
|
215
226
|
# Responses"}[https://www.rfc-editor.org/rfc/rfc3501#section-7.1] for full
|
|
@@ -240,24 +251,24 @@ module Net
|
|
|
240
251
|
# the <tt>\Seen</tt> flag set.
|
|
241
252
|
# <em>DEPRECATED by IMAP4rev2.</em>
|
|
242
253
|
#
|
|
243
|
-
#
|
|
254
|
+
# === +BINARY+ extension
|
|
244
255
|
# See {[RFC3516]}[https://www.rfc-editor.org/rfc/rfc3516].
|
|
245
256
|
# * +UNKNOWN-CTE+, with a tagged +NO+ response, when the server does not
|
|
246
257
|
# known how to decode a CTE (content-transfer-encoding). #data is +nil+.
|
|
247
258
|
# See IMAP#fetch.
|
|
248
259
|
#
|
|
249
|
-
#
|
|
260
|
+
# === +UIDPLUS+ extension
|
|
250
261
|
# See {[RFC4315 §3]}[https://www.rfc-editor.org/rfc/rfc4315#section-3].
|
|
251
|
-
# * +APPENDUID+, #data is
|
|
252
|
-
# * +COPYUID+, #data is
|
|
262
|
+
# * +APPENDUID+, #data is AppendUIDData. See IMAP#append.
|
|
263
|
+
# * +COPYUID+, #data is CopyUIDData. See IMAP#copy.
|
|
253
264
|
# * +UIDNOTSTICKY+, #data is +nil+. See IMAP#select.
|
|
254
265
|
#
|
|
255
|
-
#
|
|
266
|
+
# === +SEARCHRES+ extension
|
|
256
267
|
# See {[RFC5182]}[https://www.rfc-editor.org/rfc/rfc5182].
|
|
257
268
|
# * +NOTSAVED+, with a tagged +NO+ response, when the search result variable
|
|
258
269
|
# is not saved. #data is +nil+.
|
|
259
270
|
#
|
|
260
|
-
#
|
|
271
|
+
# === +RFC5530+ response codes
|
|
261
272
|
# See {[RFC5530]}[https://www.rfc-editor.org/rfc/rfc5530], "IMAP Response
|
|
262
273
|
# Codes" for the definition of the following response codes, which are all
|
|
263
274
|
# machine-readable annotations for the human-readable ResponseText#text, and
|
|
@@ -280,22 +291,22 @@ module Net
|
|
|
280
291
|
# * +ALREADYEXISTS+
|
|
281
292
|
# * +NONEXISTENT+
|
|
282
293
|
#
|
|
283
|
-
#
|
|
294
|
+
# === +QRESYNC+ extension
|
|
284
295
|
# See {[RFC7162]}[https://www.rfc-editor.org/rfc/rfc7162.html].
|
|
285
296
|
# * +CLOSED+, returned when the currently selected mailbox is closed
|
|
286
297
|
# implicitly by selecting or examining another mailbox. #data is +nil+.
|
|
287
298
|
#
|
|
288
|
-
#
|
|
299
|
+
# === +IMAP4rev2+ response codes
|
|
289
300
|
# See {[RFC9051]}[https://www.rfc-editor.org/rfc/rfc9051] {§7.1, "Server
|
|
290
301
|
# Responses - Status
|
|
291
302
|
# Responses"}[https://www.rfc-editor.org/rfc/rfc9051#section-7.1] for full
|
|
292
303
|
# descriptions of IMAP4rev2 response codes. IMAP4rev2 includes all of the
|
|
293
|
-
# response codes listed above (except "UNSEEN") and adds the following:
|
|
304
|
+
# response codes listed above (except "+UNSEEN+") and adds the following:
|
|
294
305
|
# * +HASCHILDREN+, with a tagged +NO+ response, when a mailbox delete failed
|
|
295
306
|
# because the server doesn't allow deletion of mailboxes with children.
|
|
296
307
|
# #data is +nil+.
|
|
297
308
|
#
|
|
298
|
-
#
|
|
309
|
+
# === +CONDSTORE+ extension
|
|
299
310
|
# See {[RFC7162]}[https://www.rfc-editor.org/rfc/rfc7162.html].
|
|
300
311
|
# * +NOMODSEQ+, when selecting a mailbox that does not support
|
|
301
312
|
# mod-sequences. #data is +nil+. See IMAP#select.
|
|
@@ -305,10 +316,17 @@ module Net
|
|
|
305
316
|
# since the +UNCHANGEDSINCE+ mod-sequence given to +STORE+ or <tt>UID
|
|
306
317
|
# STORE</tt>.
|
|
307
318
|
#
|
|
308
|
-
#
|
|
319
|
+
# === +OBJECTID+ extension
|
|
309
320
|
# See {[RFC8474]}[https://www.rfc-editor.org/rfc/rfc8474.html].
|
|
310
321
|
# * +MAILBOXID+, #data is a string
|
|
311
322
|
#
|
|
323
|
+
# == Extension compatibility
|
|
324
|
+
#
|
|
325
|
+
# Response codes are backwards compatible: Servers are allowed to send new
|
|
326
|
+
# response codes even if the client has not enabled the extension that
|
|
327
|
+
# defines them. When Net::IMAP does not know how to parse response
|
|
328
|
+
# code text, #data returns the unparsed string.
|
|
329
|
+
#
|
|
312
330
|
class ResponseCode < Struct.new(:name, :data)
|
|
313
331
|
##
|
|
314
332
|
# method: name
|
|
@@ -327,10 +345,8 @@ module Net
|
|
|
327
345
|
# code data can take.
|
|
328
346
|
end
|
|
329
347
|
|
|
330
|
-
#
|
|
331
|
-
#
|
|
332
|
-
#
|
|
333
|
-
# Net::IMAP#list returns an array of MailboxList objects.
|
|
348
|
+
# MailboxList represents the data of an untagged +LIST+ response, for a
|
|
349
|
+
# _single_ mailbox path. IMAP#list returns an array of MailboxList objects.
|
|
334
350
|
#
|
|
335
351
|
class MailboxList < Struct.new(:attr, :delim, :name)
|
|
336
352
|
##
|
|
@@ -340,11 +356,11 @@ module Net
|
|
|
340
356
|
# Returns the name attributes. Each name attribute is a symbol capitalized
|
|
341
357
|
# by String#capitalize, such as :Noselect (not :NoSelect). For the
|
|
342
358
|
# semantics of each attribute, see:
|
|
343
|
-
# *
|
|
344
|
-
# *
|
|
345
|
-
# * Net::IMAP@SPECIAL-USE
|
|
359
|
+
# * Net::IMAP@Basic+Mailbox+Attributes
|
|
360
|
+
# * Net::IMAP@Mailbox+role+Attributes
|
|
346
361
|
# * The IANA {IMAP Mailbox Name Attributes
|
|
347
362
|
# registry}[https://www.iana.org/assignments/imap-mailbox-name-attributes/imap-mailbox-name-attributes.xhtml]
|
|
363
|
+
# has links to specifications for all standard mailbox attributes.
|
|
348
364
|
|
|
349
365
|
##
|
|
350
366
|
# method: delim
|
|
@@ -359,16 +375,16 @@ module Net
|
|
|
359
375
|
# Returns the mailbox name.
|
|
360
376
|
end
|
|
361
377
|
|
|
362
|
-
#
|
|
363
|
-
# This object can also be a response to GETQUOTAROOT. In the syntax
|
|
364
|
-
# specification below, the delimiter used with the "#" construct is a
|
|
365
|
-
# single space (SPACE).
|
|
378
|
+
# MailboxQuota represents the data of an untagged +QUOTA+ response.
|
|
366
379
|
#
|
|
367
|
-
#
|
|
380
|
+
# IMAP#getquota returns an array of MailboxQuota objects.
|
|
368
381
|
#
|
|
369
382
|
# Net::IMAP#getquotaroot returns an array containing both MailboxQuotaRoot
|
|
370
383
|
# and MailboxQuota objects.
|
|
371
384
|
#
|
|
385
|
+
# == Required capability
|
|
386
|
+
# Requires +QUOTA+ [RFC2087[https://www.rfc-editor.org/rfc/rfc2087]]
|
|
387
|
+
# capability.
|
|
372
388
|
class MailboxQuota < Struct.new(:mailbox, :usage, :quota)
|
|
373
389
|
##
|
|
374
390
|
# method: mailbox
|
|
@@ -390,12 +406,14 @@ module Net
|
|
|
390
406
|
#
|
|
391
407
|
end
|
|
392
408
|
|
|
393
|
-
#
|
|
394
|
-
# response. (GETQUOTAROOT can also return Net::IMAP::MailboxQuota.)
|
|
409
|
+
# MailboxQuotaRoot represents the data of an untagged +QUOTAROOT+ response.
|
|
395
410
|
#
|
|
396
|
-
#
|
|
397
|
-
#
|
|
411
|
+
# IMAP#getquotaroot returns an array containing both MailboxQuotaRoot and
|
|
412
|
+
# MailboxQuota objects.
|
|
398
413
|
#
|
|
414
|
+
# == Required capability
|
|
415
|
+
# Requires +QUOTA+ [RFC2087[https://www.rfc-editor.org/rfc/rfc2087]]
|
|
416
|
+
# capability.
|
|
399
417
|
class MailboxQuotaRoot < Struct.new(:mailbox, :quotaroots)
|
|
400
418
|
##
|
|
401
419
|
# method: mailbox
|
|
@@ -410,12 +428,13 @@ module Net
|
|
|
410
428
|
# Zero or more quotaroots that affect the quota on the specified mailbox.
|
|
411
429
|
end
|
|
412
430
|
|
|
413
|
-
#
|
|
431
|
+
# MailboxACLItem represents the data of an untagged +ACL+ response.
|
|
414
432
|
#
|
|
415
|
-
#
|
|
433
|
+
# IMAP#getacl returns an array of MailboxACLItem objects.
|
|
416
434
|
#
|
|
417
|
-
#
|
|
418
|
-
# +ACL+
|
|
435
|
+
# == Required capability
|
|
436
|
+
# Requires +ACL+ [RFC4314[https://www.rfc-editor.org/rfc/rfc4314]]
|
|
437
|
+
# capability.
|
|
419
438
|
class MailboxACLItem < Struct.new(:user, :rights, :mailbox)
|
|
420
439
|
##
|
|
421
440
|
# method: mailbox
|
|
@@ -437,11 +456,12 @@ module Net
|
|
|
437
456
|
# The access rights the indicated #user has to the #mailbox.
|
|
438
457
|
end
|
|
439
458
|
|
|
440
|
-
#
|
|
441
|
-
#
|
|
442
|
-
#
|
|
443
|
-
# Returned by Net::IMAP#namespace, contained inside a Namespaces object.
|
|
459
|
+
# Namespace represents a _single_ namespace, contained inside a Namespaces
|
|
460
|
+
# object.
|
|
444
461
|
#
|
|
462
|
+
# == Required capability
|
|
463
|
+
# Requires either +NAMESPACE+ [RFC2342[https://www.rfc-editor.org/rfc/rfc2342]]
|
|
464
|
+
# or +IMAP4rev2+ capability.
|
|
445
465
|
class Namespace < Struct.new(:prefix, :delim, :extensions)
|
|
446
466
|
##
|
|
447
467
|
# method: prefix
|
|
@@ -463,11 +483,14 @@ module Net
|
|
|
463
483
|
# Extension parameter semantics would be defined by the extension.
|
|
464
484
|
end
|
|
465
485
|
|
|
466
|
-
#
|
|
467
|
-
#
|
|
486
|
+
# Namespaces represents the data of an untagged +NAMESPACE+ response,
|
|
487
|
+
# returned by IMAP#namespace.
|
|
468
488
|
#
|
|
469
|
-
#
|
|
489
|
+
# Contains lists of #personal, #shared, and #other namespaces.
|
|
470
490
|
#
|
|
491
|
+
# == Required capability
|
|
492
|
+
# Requires either +NAMESPACE+ [RFC2342[https://www.rfc-editor.org/rfc/rfc2342]]
|
|
493
|
+
# or +IMAP4rev2+ capability.
|
|
471
494
|
class Namespaces < Struct.new(:personal, :other, :shared)
|
|
472
495
|
##
|
|
473
496
|
# method: personal
|
|
@@ -488,9 +511,9 @@ module Net
|
|
|
488
511
|
# Returns an array of Shared Namespace objects.
|
|
489
512
|
end
|
|
490
513
|
|
|
491
|
-
#
|
|
514
|
+
# StatusData represents the contents of an untagged +STATUS+ response.
|
|
492
515
|
#
|
|
493
|
-
#
|
|
516
|
+
# IMAP#status returns the contents of #attr.
|
|
494
517
|
class StatusData < Struct.new(:mailbox, :attr)
|
|
495
518
|
##
|
|
496
519
|
# method: mailbox
|
|
@@ -511,11 +534,11 @@ module Net
|
|
|
511
534
|
# [Note]
|
|
512
535
|
# When the #sender and #reply_to fields are absent or empty, they will
|
|
513
536
|
# return the same value as #from. Also, fields may return values that are
|
|
514
|
-
# invalid for well-formed [RFC5322[https://
|
|
537
|
+
# invalid for well-formed [RFC5322[https://www.rfc-editor.org/rfc/rfc5322]]
|
|
515
538
|
# messages when the message is malformed or a draft message.
|
|
516
539
|
#
|
|
517
|
-
# See [{IMAP4rev1 §7.4.2}[https://www.rfc-editor.org/rfc/rfc3501
|
|
518
|
-
# and [{IMAP4rev2 §7.5.2}[https://www.rfc-editor.org/rfc/rfc9051
|
|
540
|
+
# See [{IMAP4rev1 §7.4.2}[https://www.rfc-editor.org/rfc/rfc3501#section-7.4.2]]
|
|
541
|
+
# and [{IMAP4rev2 §7.5.2}[https://www.rfc-editor.org/rfc/rfc9051#section-7.5.2]]
|
|
519
542
|
# for full description of the envelope fields, and
|
|
520
543
|
# Net::IMAP@Message+envelope+and+body+structure for other relevant RFCs.
|
|
521
544
|
#
|
|
@@ -529,7 +552,7 @@ module Net
|
|
|
529
552
|
# Returns a string that represents the +Date+ header.
|
|
530
553
|
#
|
|
531
554
|
# [Note]
|
|
532
|
-
# For a well-formed [RFC5322[https://
|
|
555
|
+
# For a well-formed [RFC5322[https://www.rfc-editor.org/rfc/rfc5322]]
|
|
533
556
|
# message, the #date field must not be +nil+. However it can be +nil+
|
|
534
557
|
# for a malformed or draft message.
|
|
535
558
|
|
|
@@ -555,7 +578,7 @@ module Net
|
|
|
555
578
|
# returns +nil+ for this envelope field.
|
|
556
579
|
#
|
|
557
580
|
# [Note]
|
|
558
|
-
# For a well-formed [RFC5322[https://
|
|
581
|
+
# For a well-formed [RFC5322[https://www.rfc-editor.org/rfc/rfc5322]]
|
|
559
582
|
# message, the #from field must not be +nil+. However it can be +nil+
|
|
560
583
|
# for a malformed or draft message.
|
|
561
584
|
|
|
@@ -568,7 +591,7 @@ module Net
|
|
|
568
591
|
# [Note]
|
|
569
592
|
# If the <tt>Sender</tt> header is absent, or is present but empty, the
|
|
570
593
|
# server sets this field to be the same value as #from. Therefore, in a
|
|
571
|
-
# well-formed [RFC5322[https://
|
|
594
|
+
# well-formed [RFC5322[https://www.rfc-editor.org/rfc/rfc5322]] message,
|
|
572
595
|
# the #sender envelope field must not be +nil+. However it can be
|
|
573
596
|
# +nil+ for a malformed or draft message.
|
|
574
597
|
|
|
@@ -582,7 +605,7 @@ module Net
|
|
|
582
605
|
# [Note]
|
|
583
606
|
# If the <tt>Reply-To</tt> header is absent, or is present but empty,
|
|
584
607
|
# the server sets this field to be the same value as #from. Therefore,
|
|
585
|
-
# in a well-formed [RFC5322[https://
|
|
608
|
+
# in a well-formed [RFC5322[https://www.rfc-editor.org/rfc/rfc5322]]
|
|
586
609
|
# message, the #reply_to envelope field must not be +nil+. However it
|
|
587
610
|
# can be +nil+ for a malformed or draft message.
|
|
588
611
|
|
|
@@ -611,7 +634,7 @@ module Net
|
|
|
611
634
|
# Returns a string that represents the <tt>In-Reply-To</tt> header.
|
|
612
635
|
#
|
|
613
636
|
# [Note]
|
|
614
|
-
# For a well-formed [RFC5322[https://
|
|
637
|
+
# For a well-formed [RFC5322[https://www.rfc-editor.org/rfc/rfc5322]]
|
|
615
638
|
# message, the #in_reply_to field, if present, must not be empty. But
|
|
616
639
|
# it can still return an empty string for malformed messages.
|
|
617
640
|
#
|
|
@@ -627,7 +650,7 @@ module Net
|
|
|
627
650
|
# Returns a string that represents the <tt>Message-ID</tt>.
|
|
628
651
|
#
|
|
629
652
|
# [Note]
|
|
630
|
-
# For a well-formed [RFC5322[https://
|
|
653
|
+
# For a well-formed [RFC5322[https://www.rfc-editor.org/rfc/rfc5322]]
|
|
631
654
|
# message, the #message_id field, if present, must not be empty. But it
|
|
632
655
|
# can still return an empty string for malformed messages.
|
|
633
656
|
#
|
|
@@ -641,10 +664,10 @@ module Net
|
|
|
641
664
|
# parsed into its component parts by the server. Address objects are
|
|
642
665
|
# returned within Envelope fields.
|
|
643
666
|
#
|
|
644
|
-
#
|
|
667
|
+
# == Group syntax
|
|
645
668
|
#
|
|
646
669
|
# When the #host field is +nil+, this is a special form of address structure
|
|
647
|
-
# that indicates the [RFC5322[https://
|
|
670
|
+
# that indicates the [RFC5322[https://www.rfc-editor.org/rfc/rfc5322]] group
|
|
648
671
|
# syntax. If the #mailbox name field is also +nil+, this is an end-of-group
|
|
649
672
|
# marker (semicolon in RFC-822 syntax). If the #mailbox name field is
|
|
650
673
|
# non-+NIL+, this is the start of a group marker, and the mailbox #name
|
|
@@ -654,7 +677,7 @@ module Net
|
|
|
654
677
|
# method: name
|
|
655
678
|
# :call-seq: name -> string or nil
|
|
656
679
|
#
|
|
657
|
-
# Returns the [RFC5322[https://
|
|
680
|
+
# Returns the [RFC5322[https://www.rfc-editor.org/rfc/rfc5322]] address
|
|
658
681
|
# +display-name+ (or the mailbox +phrase+ in the RFC-822 grammar).
|
|
659
682
|
|
|
660
683
|
##
|
|
@@ -664,28 +687,28 @@ module Net
|
|
|
664
687
|
# Returns the route from RFC-822 route-addr.
|
|
665
688
|
#
|
|
666
689
|
# Note:: Generating this obsolete route addressing syntax is not allowed
|
|
667
|
-
# by [RFC5322[https://
|
|
690
|
+
# by [RFC5322[https://www.rfc-editor.org/rfc/rfc5322]]. However,
|
|
668
691
|
# addresses with this syntax must still be accepted and parsed.
|
|
669
692
|
|
|
670
693
|
##
|
|
671
694
|
# method: mailbox
|
|
672
695
|
# :call-seq: mailbox -> string or nil
|
|
673
696
|
#
|
|
674
|
-
# Returns the [RFC5322[https://
|
|
697
|
+
# Returns the [RFC5322[https://www.rfc-editor.org/rfc/rfc5322]] address
|
|
675
698
|
# +local-part+, if #host is not +nil+.
|
|
676
699
|
#
|
|
677
700
|
# When #host is +nil+, this returns
|
|
678
|
-
# an [RFC5322[https://
|
|
701
|
+
# an [RFC5322[https://www.rfc-editor.org/rfc/rfc5322]] group name and a +nil+
|
|
679
702
|
# mailbox indicates the end of a group.
|
|
680
703
|
|
|
681
704
|
##
|
|
682
705
|
# method: host
|
|
683
706
|
# :call-seq: host -> string or nil
|
|
684
707
|
#
|
|
685
|
-
# Returns the [RFC5322[https://
|
|
708
|
+
# Returns the [RFC5322[https://www.rfc-editor.org/rfc/rfc5322]] addr-spec
|
|
686
709
|
# +domain+ name.
|
|
687
710
|
#
|
|
688
|
-
# +nil+ indicates [RFC5322[https://
|
|
711
|
+
# +nil+ indicates [RFC5322[https://www.rfc-editor.org/rfc/rfc5322]] group
|
|
689
712
|
# syntax.
|
|
690
713
|
end
|
|
691
714
|
|
|
@@ -697,14 +720,14 @@ module Net
|
|
|
697
720
|
# :call-seq: dsp_type -> string
|
|
698
721
|
#
|
|
699
722
|
# Returns the content disposition type, as defined by
|
|
700
|
-
# [DISPOSITION[https://
|
|
723
|
+
# [DISPOSITION[https://www.rfc-editor.org/rfc/rfc2183]].
|
|
701
724
|
|
|
702
725
|
##
|
|
703
726
|
# method: param
|
|
704
727
|
# :call-seq: param -> hash
|
|
705
728
|
#
|
|
706
729
|
# Returns a hash representing parameters of the Content-Disposition
|
|
707
|
-
# field, as defined by [DISPOSITION[https://
|
|
730
|
+
# field, as defined by [DISPOSITION[https://www.rfc-editor.org/rfc/rfc2183]].
|
|
708
731
|
end
|
|
709
732
|
|
|
710
733
|
# Net::IMAP::ThreadMember represents a thread-node returned
|
|
@@ -743,12 +766,12 @@ module Net
|
|
|
743
766
|
# FetchData#attr value. Although these classes don't share a base class,
|
|
744
767
|
# this module can be used to pattern match all of them.
|
|
745
768
|
#
|
|
746
|
-
# See {[IMAP4rev1] §7.4.2}[https://www.rfc-editor.org/rfc/rfc3501
|
|
747
|
-
# and {[IMAP4rev2] §7.5.2}[https://www.rfc-editor.org/rfc/rfc9051
|
|
769
|
+
# See {[IMAP4rev1] §7.4.2}[https://www.rfc-editor.org/rfc/rfc3501#section-7.4.2]
|
|
770
|
+
# and {[IMAP4rev2] §7.5.2}[https://www.rfc-editor.org/rfc/rfc9051#section-7.5.2-4.9]
|
|
748
771
|
# for full description of all +BODYSTRUCTURE+ fields, and also
|
|
749
772
|
# Net::IMAP@Message+envelope+and+body+structure for other relevant RFCs.
|
|
750
773
|
#
|
|
751
|
-
#
|
|
774
|
+
# == Classes that include BodyStructure
|
|
752
775
|
# BodyTypeBasic:: Represents any message parts that are not handled by
|
|
753
776
|
# BodyTypeText, BodyTypeMessage, or BodyTypeMultipart.
|
|
754
777
|
# BodyTypeText:: Used by <tt>text/*</tt> parts. Contains all of the
|
|
@@ -766,8 +789,8 @@ module Net
|
|
|
766
789
|
# message parts, unless they have a <tt>Content-Type</tt> that is handled by
|
|
767
790
|
# BodyTypeText, BodyTypeMessage, or BodyTypeMultipart.
|
|
768
791
|
#
|
|
769
|
-
# See {[IMAP4rev1] §7.4.2}[https://www.rfc-editor.org/rfc/rfc3501
|
|
770
|
-
# and {[IMAP4rev2] §7.5.2}[https://www.rfc-editor.org/rfc/rfc9051
|
|
792
|
+
# See {[IMAP4rev1] §7.4.2}[https://www.rfc-editor.org/rfc/rfc3501#section-7.4.2]
|
|
793
|
+
# and {[IMAP4rev2] §7.5.2}[https://www.rfc-editor.org/rfc/rfc9051#section-7.5.2-4.9]
|
|
771
794
|
# for full description of all +BODYSTRUCTURE+ fields, and also
|
|
772
795
|
# Net::IMAP@Message+envelope+and+body+structure for other relevant RFCs.
|
|
773
796
|
#
|
|
@@ -784,45 +807,45 @@ module Net
|
|
|
784
807
|
# :call-seq: media_type -> string
|
|
785
808
|
#
|
|
786
809
|
# The top-level media type as defined in
|
|
787
|
-
# [MIME-IMB[https://
|
|
810
|
+
# [MIME-IMB[https://www.rfc-editor.org/rfc/rfc2045]].
|
|
788
811
|
|
|
789
812
|
##
|
|
790
813
|
# method: subtype
|
|
791
814
|
# :call-seq: subtype -> string
|
|
792
815
|
#
|
|
793
816
|
# The media subtype name as defined in
|
|
794
|
-
# [MIME-IMB[https://
|
|
817
|
+
# [MIME-IMB[https://www.rfc-editor.org/rfc/rfc2045]].
|
|
795
818
|
|
|
796
819
|
##
|
|
797
820
|
# method: param
|
|
798
821
|
# :call-seq: param -> string
|
|
799
822
|
#
|
|
800
823
|
# Returns a hash that represents parameters as defined in
|
|
801
|
-
# [MIME-IMB[https://
|
|
824
|
+
# [MIME-IMB[https://www.rfc-editor.org/rfc/rfc2045]].
|
|
802
825
|
|
|
803
826
|
##
|
|
804
827
|
# method: content_id
|
|
805
828
|
# :call-seq: content_id -> string
|
|
806
829
|
#
|
|
807
830
|
# Returns a string giving the content id as defined
|
|
808
|
-
# in [MIME-IMB[https://
|
|
809
|
-
# {§7}[https://
|
|
831
|
+
# in [MIME-IMB[https://www.rfc-editor.org/rfc/rfc2045]]
|
|
832
|
+
# {§7}[https://www.rfc-editor.org/rfc/rfc2045#section-7].
|
|
810
833
|
|
|
811
834
|
##
|
|
812
835
|
# method: description
|
|
813
836
|
# :call-seq: description -> string
|
|
814
837
|
#
|
|
815
838
|
# Returns a string giving the content description as defined
|
|
816
|
-
# in [MIME-IMB[https://
|
|
817
|
-
# {§8}[https://
|
|
839
|
+
# in [MIME-IMB[https://www.rfc-editor.org/rfc/rfc2045]]
|
|
840
|
+
# {§8}[https://www.rfc-editor.org/rfc/rfc2045#section-8].
|
|
818
841
|
|
|
819
842
|
##
|
|
820
843
|
# method: encoding
|
|
821
844
|
# :call-seq: encoding -> string
|
|
822
845
|
#
|
|
823
846
|
# Returns a string giving the content transfer encoding as defined
|
|
824
|
-
# in [MIME-IMB[https://
|
|
825
|
-
# {§6}[https://
|
|
847
|
+
# in [MIME-IMB[https://www.rfc-editor.org/rfc/rfc2045]]
|
|
848
|
+
# {§6}[https://www.rfc-editor.org/rfc/rfc2045#section-6].
|
|
826
849
|
|
|
827
850
|
##
|
|
828
851
|
# method: size
|
|
@@ -835,7 +858,7 @@ module Net
|
|
|
835
858
|
# :call-seq: md5 -> string
|
|
836
859
|
#
|
|
837
860
|
# Returns a string giving the body MD5 value as defined in
|
|
838
|
-
# [MD5[https://
|
|
861
|
+
# [MD5[https://www.rfc-editor.org/rfc/rfc1864]].
|
|
839
862
|
|
|
840
863
|
##
|
|
841
864
|
# method: disposition
|
|
@@ -843,7 +866,7 @@ module Net
|
|
|
843
866
|
#
|
|
844
867
|
# Returns a ContentDisposition object giving the content
|
|
845
868
|
# disposition, as defined by
|
|
846
|
-
# [DISPOSITION[https://
|
|
869
|
+
# [DISPOSITION[https://www.rfc-editor.org/rfc/rfc2183]].
|
|
847
870
|
|
|
848
871
|
##
|
|
849
872
|
# method: language
|
|
@@ -888,7 +911,8 @@ module Net
|
|
|
888
911
|
# for something else?
|
|
889
912
|
#++
|
|
890
913
|
def media_subtype
|
|
891
|
-
warn("media_subtype is obsolete, use subtype instead.\n",
|
|
914
|
+
warn("media_subtype is obsolete, use subtype instead.\n",
|
|
915
|
+
uplevel: 1, category: :deprecated)
|
|
892
916
|
return subtype
|
|
893
917
|
end
|
|
894
918
|
end
|
|
@@ -933,7 +957,8 @@ module Net
|
|
|
933
957
|
# generate a warning message to +stderr+, then return
|
|
934
958
|
# the value of +subtype+.
|
|
935
959
|
def media_subtype
|
|
936
|
-
warn("media_subtype is obsolete, use subtype instead.\n",
|
|
960
|
+
warn("media_subtype is obsolete, use subtype instead.\n",
|
|
961
|
+
uplevel: 1, category: :deprecated)
|
|
937
962
|
return subtype
|
|
938
963
|
end
|
|
939
964
|
end
|
|
@@ -989,77 +1014,6 @@ module Net
|
|
|
989
1014
|
end
|
|
990
1015
|
end
|
|
991
1016
|
|
|
992
|
-
# BodyTypeAttachment is not used and will be removed in an upcoming release.
|
|
993
|
-
#
|
|
994
|
-
# === Bug Analysis
|
|
995
|
-
#
|
|
996
|
-
# \IMAP body structures are parenthesized lists and assign their fields
|
|
997
|
-
# positionally, so missing fields change the interpretation of all
|
|
998
|
-
# following fields. Additionally, different body types have a different
|
|
999
|
-
# number of required fields, followed by optional "extension" fields.
|
|
1000
|
-
#
|
|
1001
|
-
# BodyTypeAttachment was previously returned when a "message/rfc822" part,
|
|
1002
|
-
# which should be sent as <tt>body-type-msg</tt> with ten required fields,
|
|
1003
|
-
# was actually sent as a <tt>body-type-basic</tt> with _seven_ required
|
|
1004
|
-
# fields.
|
|
1005
|
-
#
|
|
1006
|
-
# basic => type, subtype, param, id, desc, enc, octets, md5=nil, dsp=nil, lang=nil, loc=nil, *ext
|
|
1007
|
-
# msg => type, subtype, param, id, desc, enc, octets, envelope, body, lines, md5=nil, ...
|
|
1008
|
-
#
|
|
1009
|
-
# Normally, +envelope+ and +md5+ are incompatible, but Net::IMAP leniently
|
|
1010
|
-
# allowed buggy servers to send +NIL+ for +envelope+. As a result, when a
|
|
1011
|
-
# server sent a <tt>message/rfc822</tt> part with +NIL+ for +md5+ and a
|
|
1012
|
-
# non-<tt>NIL</tt> +dsp+, Net::IMAP misinterpreted the
|
|
1013
|
-
# <tt>Content-Disposition</tt> as if it were a strange body type. In all
|
|
1014
|
-
# reported cases, the <tt>Content-Disposition</tt> was "attachment", so
|
|
1015
|
-
# BodyTypeAttachment was created as the workaround.
|
|
1016
|
-
#
|
|
1017
|
-
# === Current behavior
|
|
1018
|
-
#
|
|
1019
|
-
# When interpreted strictly, +envelope+ and +md5+ are incompatible. So the
|
|
1020
|
-
# current parsing algorithm peeks ahead after it has received the seventh
|
|
1021
|
-
# body field. If the next token is not the start of an +envelope+, we assume
|
|
1022
|
-
# the server has incorrectly sent us a <tt>body-type-basic</tt> and return
|
|
1023
|
-
# BodyTypeBasic. As a result, what was previously BodyTypeMessage#body =>
|
|
1024
|
-
# BodyTypeAttachment is now BodyTypeBasic#disposition => ContentDisposition.
|
|
1025
|
-
#
|
|
1026
|
-
class BodyTypeAttachment < Struct.new(:dsp_type, :_unused_, :param)
|
|
1027
|
-
# *invalid for BodyTypeAttachment*
|
|
1028
|
-
def media_type
|
|
1029
|
-
warn(<<~WARN, uplevel: 1)
|
|
1030
|
-
BodyTypeAttachment#media_type is obsolete. Use dsp_type instead.
|
|
1031
|
-
WARN
|
|
1032
|
-
dsp_type
|
|
1033
|
-
end
|
|
1034
|
-
|
|
1035
|
-
# *invalid for BodyTypeAttachment*
|
|
1036
|
-
def subtype
|
|
1037
|
-
warn("BodyTypeAttachment#subtype is obsolete.\n", uplevel: 1)
|
|
1038
|
-
nil
|
|
1039
|
-
end
|
|
1040
|
-
|
|
1041
|
-
##
|
|
1042
|
-
# method: dsp_type
|
|
1043
|
-
# :call-seq: dsp_type -> string
|
|
1044
|
-
#
|
|
1045
|
-
# Returns the content disposition type, as defined by
|
|
1046
|
-
# [DISPOSITION[https://tools.ietf.org/html/rfc2183]].
|
|
1047
|
-
|
|
1048
|
-
##
|
|
1049
|
-
# method: param
|
|
1050
|
-
# :call-seq: param -> hash
|
|
1051
|
-
#
|
|
1052
|
-
# Returns a hash representing parameters of the Content-Disposition
|
|
1053
|
-
# field, as defined by [DISPOSITION[https://tools.ietf.org/html/rfc2183]].
|
|
1054
|
-
|
|
1055
|
-
##
|
|
1056
|
-
def multipart?
|
|
1057
|
-
return false
|
|
1058
|
-
end
|
|
1059
|
-
end
|
|
1060
|
-
|
|
1061
|
-
deprecate_constant :BodyTypeAttachment
|
|
1062
|
-
|
|
1063
1017
|
# Net::IMAP::BodyTypeMultipart represents body structures of messages and
|
|
1064
1018
|
# message parts, when <tt>Content-Type</tt> is <tt>multipart/*</tt>.
|
|
1065
1019
|
class BodyTypeMultipart < Struct.new(:media_type, :subtype,
|
|
@@ -1080,7 +1034,7 @@ module Net
|
|
|
1080
1034
|
# call-seq: subtype -> string
|
|
1081
1035
|
#
|
|
1082
1036
|
# Returns the content subtype name
|
|
1083
|
-
# as defined in [MIME-IMB[https://
|
|
1037
|
+
# as defined in [MIME-IMB[https://www.rfc-editor.org/rfc/rfc2045]].
|
|
1084
1038
|
|
|
1085
1039
|
##
|
|
1086
1040
|
# method: parts
|
|
@@ -1094,7 +1048,7 @@ module Net
|
|
|
1094
1048
|
# call-seq: param -> hash
|
|
1095
1049
|
#
|
|
1096
1050
|
# Returns a hash that represents parameters
|
|
1097
|
-
# as defined in [MIME-IMB[https://
|
|
1051
|
+
# as defined in [MIME-IMB[https://www.rfc-editor.org/rfc/rfc2045]].
|
|
1098
1052
|
|
|
1099
1053
|
##
|
|
1100
1054
|
# method: disposition
|
|
@@ -1131,29 +1085,11 @@ module Net
|
|
|
1131
1085
|
# generate a warning message to +stderr+, then return
|
|
1132
1086
|
# the value of +subtype+.
|
|
1133
1087
|
def media_subtype
|
|
1134
|
-
warn("media_subtype is obsolete, use subtype instead.\n",
|
|
1088
|
+
warn("media_subtype is obsolete, use subtype instead.\n",
|
|
1089
|
+
uplevel: 1, category: :deprecated)
|
|
1135
1090
|
return subtype
|
|
1136
1091
|
end
|
|
1137
1092
|
end
|
|
1138
1093
|
|
|
1139
|
-
# === Obsolete
|
|
1140
|
-
# BodyTypeExtension is not used and will be removed in an upcoming release.
|
|
1141
|
-
#
|
|
1142
|
-
# >>>
|
|
1143
|
-
# BodyTypeExtension was (incorrectly) used for <tt>message/*</tt> parts
|
|
1144
|
-
# (besides <tt>message/rfc822</tt>, which correctly uses BodyTypeMessage).
|
|
1145
|
-
#
|
|
1146
|
-
# Net::IMAP now (correctly) parses all message types (other than
|
|
1147
|
-
# <tt>message/rfc822</tt> or <tt>message/global</tt>) as BodyTypeBasic.
|
|
1148
|
-
class BodyTypeExtension < Struct.new(:media_type, :subtype,
|
|
1149
|
-
:params, :content_id,
|
|
1150
|
-
:description, :encoding, :size)
|
|
1151
|
-
def multipart?
|
|
1152
|
-
return false
|
|
1153
|
-
end
|
|
1154
|
-
end
|
|
1155
|
-
|
|
1156
|
-
deprecate_constant :BodyTypeExtension
|
|
1157
|
-
|
|
1158
1094
|
end
|
|
1159
1095
|
end
|