net-imap 0.4.24 → 0.5.14
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 +10 -1
- 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 +73 -78
- data/lib/net/imap/config/attr_type_coercion.rb +22 -10
- data/lib/net/imap/config/attr_version_defaults.rb +93 -0
- data/lib/net/imap/config.rb +70 -94
- data/lib/net/imap/connection_state.rb +48 -0
- data/lib/net/imap/data_encoding.rb +3 -3
- data/lib/net/imap/data_lite.rb +226 -0
- data/lib/net/imap/deprecated_client_options.rb +6 -3
- data/lib/net/imap/errors.rb +6 -0
- data/lib/net/imap/esearch_result.rb +219 -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 +120 -186
- data/lib/net/imap/response_parser/parser_utils.rb +5 -0
- data/lib/net/imap/response_parser.rb +155 -21
- data/lib/net/imap/response_reader.rb +9 -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 +10 -10
- data/lib/net/imap/sasl.rb +7 -4
- data/lib/net/imap/sasl_adapter.rb +0 -1
- data/lib/net/imap/search_result.rb +4 -5
- data/lib/net/imap/sequence_set.rb +529 -154
- 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 +2 -84
- data/lib/net/imap/vanished_data.rb +65 -0
- data/lib/net/imap.rb +996 -305
- data/net-imap.gemspec +1 -1
- data/rakelib/rfcs.rake +2 -0
- data/rakelib/string_prep_tables_generator.rb +6 -2
- metadata +7 -2
|
@@ -2,12 +2,14 @@
|
|
|
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
9
|
autoload :UIDPlusData, "#{__dir__}/uidplus_data"
|
|
9
10
|
autoload :AppendUIDData, "#{__dir__}/uidplus_data"
|
|
10
11
|
autoload :CopyUIDData, "#{__dir__}/uidplus_data"
|
|
12
|
+
autoload :VanishedData, "#{__dir__}/vanished_data"
|
|
11
13
|
|
|
12
14
|
# Net::IMAP::ContinuationRequest represents command continuation requests.
|
|
13
15
|
#
|
|
@@ -160,13 +162,20 @@ module Net
|
|
|
160
162
|
# The raw response data.
|
|
161
163
|
end
|
|
162
164
|
|
|
163
|
-
#
|
|
165
|
+
# ResponseText represents texts of responses.
|
|
164
166
|
#
|
|
165
167
|
# The text may be prefixed by a ResponseCode.
|
|
166
168
|
#
|
|
167
|
-
# ResponseText is returned from TaggedResponse#data
|
|
168
|
-
# UntaggedResponse#data
|
|
169
|
-
# "
|
|
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).
|
|
170
179
|
class ResponseText < Struct.new(:code, :text)
|
|
171
180
|
# Used to avoid an allocation when ResponseText is empty
|
|
172
181
|
EMPTY = new(nil, "").freeze
|
|
@@ -184,32 +193,35 @@ module Net
|
|
|
184
193
|
# Returns the response text, not including any response code
|
|
185
194
|
end
|
|
186
195
|
|
|
187
|
-
#
|
|
188
|
-
#
|
|
189
|
-
#
|
|
190
|
-
#
|
|
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).
|
|
191
206
|
#
|
|
192
207
|
# Some response codes come with additional data which will be parsed by
|
|
193
208
|
# Net::IMAP. Others return +nil+ for #data, but are used as a
|
|
194
209
|
# machine-readable annotation for the human-readable ResponseText#text in
|
|
195
|
-
# the same response.
|
|
196
|
-
# code text, #data returns the unparsed string.
|
|
210
|
+
# the same response.
|
|
197
211
|
#
|
|
198
212
|
# Untagged response code #data is pushed directly onto Net::IMAP#responses,
|
|
199
213
|
# keyed by #name, unless it is removed by the command that generated it.
|
|
200
214
|
# Use Net::IMAP#add_response_handler to view tagged response codes for
|
|
201
215
|
# command methods that do not return their TaggedResponse.
|
|
202
216
|
#
|
|
217
|
+
# == Standard response codes
|
|
218
|
+
#
|
|
203
219
|
# \IMAP extensions may define new codes and the data that comes with them.
|
|
204
220
|
# The IANA {IMAP Response
|
|
205
221
|
# Codes}[https://www.iana.org/assignments/imap-response-codes/imap-response-codes.xhtml]
|
|
206
222
|
# 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
223
|
#
|
|
212
|
-
#
|
|
224
|
+
# === +IMAP4rev1+ response codes
|
|
213
225
|
# See [IMAP4rev1[https://www.rfc-editor.org/rfc/rfc3501]] {§7.1, "Server
|
|
214
226
|
# Responses - Status
|
|
215
227
|
# Responses"}[https://www.rfc-editor.org/rfc/rfc3501#section-7.1] for full
|
|
@@ -240,24 +252,24 @@ module Net
|
|
|
240
252
|
# the <tt>\Seen</tt> flag set.
|
|
241
253
|
# <em>DEPRECATED by IMAP4rev2.</em>
|
|
242
254
|
#
|
|
243
|
-
#
|
|
255
|
+
# === +BINARY+ extension
|
|
244
256
|
# See {[RFC3516]}[https://www.rfc-editor.org/rfc/rfc3516].
|
|
245
257
|
# * +UNKNOWN-CTE+, with a tagged +NO+ response, when the server does not
|
|
246
258
|
# known how to decode a CTE (content-transfer-encoding). #data is +nil+.
|
|
247
259
|
# See IMAP#fetch.
|
|
248
260
|
#
|
|
249
|
-
#
|
|
261
|
+
# === +UIDPLUS+ extension
|
|
250
262
|
# See {[RFC4315 §3]}[https://www.rfc-editor.org/rfc/rfc4315#section-3].
|
|
251
263
|
# * +APPENDUID+, #data is UIDPlusData. See IMAP#append.
|
|
252
264
|
# * +COPYUID+, #data is UIDPlusData. See IMAP#copy.
|
|
253
265
|
# * +UIDNOTSTICKY+, #data is +nil+. See IMAP#select.
|
|
254
266
|
#
|
|
255
|
-
#
|
|
267
|
+
# === +SEARCHRES+ extension
|
|
256
268
|
# See {[RFC5182]}[https://www.rfc-editor.org/rfc/rfc5182].
|
|
257
269
|
# * +NOTSAVED+, with a tagged +NO+ response, when the search result variable
|
|
258
270
|
# is not saved. #data is +nil+.
|
|
259
271
|
#
|
|
260
|
-
#
|
|
272
|
+
# === +RFC5530+ response codes
|
|
261
273
|
# See {[RFC5530]}[https://www.rfc-editor.org/rfc/rfc5530], "IMAP Response
|
|
262
274
|
# Codes" for the definition of the following response codes, which are all
|
|
263
275
|
# machine-readable annotations for the human-readable ResponseText#text, and
|
|
@@ -280,22 +292,22 @@ module Net
|
|
|
280
292
|
# * +ALREADYEXISTS+
|
|
281
293
|
# * +NONEXISTENT+
|
|
282
294
|
#
|
|
283
|
-
#
|
|
295
|
+
# === +QRESYNC+ extension
|
|
284
296
|
# See {[RFC7162]}[https://www.rfc-editor.org/rfc/rfc7162.html].
|
|
285
297
|
# * +CLOSED+, returned when the currently selected mailbox is closed
|
|
286
298
|
# implicitly by selecting or examining another mailbox. #data is +nil+.
|
|
287
299
|
#
|
|
288
|
-
#
|
|
300
|
+
# === +IMAP4rev2+ response codes
|
|
289
301
|
# See {[RFC9051]}[https://www.rfc-editor.org/rfc/rfc9051] {§7.1, "Server
|
|
290
302
|
# Responses - Status
|
|
291
303
|
# Responses"}[https://www.rfc-editor.org/rfc/rfc9051#section-7.1] for full
|
|
292
304
|
# descriptions of IMAP4rev2 response codes. IMAP4rev2 includes all of the
|
|
293
|
-
# response codes listed above (except "UNSEEN") and adds the following:
|
|
305
|
+
# response codes listed above (except "+UNSEEN+") and adds the following:
|
|
294
306
|
# * +HASCHILDREN+, with a tagged +NO+ response, when a mailbox delete failed
|
|
295
307
|
# because the server doesn't allow deletion of mailboxes with children.
|
|
296
308
|
# #data is +nil+.
|
|
297
309
|
#
|
|
298
|
-
#
|
|
310
|
+
# === <tt>QUOTA=RES-*</tt> response codes
|
|
299
311
|
# See {[RFC9208]}[https://www.rfc-editor.org/rfc/rfc9208.html#section-4.3].
|
|
300
312
|
# * +OVERQUOTA+ (also in RFC5530[https://www.rfc-editor.org/rfc/rfc5530]),
|
|
301
313
|
# with a tagged +NO+ response to an +APPEND+/+COPY+/+MOVE+ command when
|
|
@@ -303,7 +315,7 @@ module Net
|
|
|
303
315
|
# untagged +NO+ when a mailbox exceeds a soft quota (which may be caused
|
|
304
316
|
# be external events). #data is +nil+.
|
|
305
317
|
#
|
|
306
|
-
#
|
|
318
|
+
# === +CONDSTORE+ extension
|
|
307
319
|
# See {[RFC7162]}[https://www.rfc-editor.org/rfc/rfc7162.html].
|
|
308
320
|
# * +NOMODSEQ+, when selecting a mailbox that does not support
|
|
309
321
|
# mod-sequences. #data is +nil+. See IMAP#select.
|
|
@@ -313,10 +325,17 @@ module Net
|
|
|
313
325
|
# since the +UNCHANGEDSINCE+ mod-sequence given to +STORE+ or <tt>UID
|
|
314
326
|
# STORE</tt>.
|
|
315
327
|
#
|
|
316
|
-
#
|
|
328
|
+
# === +OBJECTID+ extension
|
|
317
329
|
# See {[RFC8474]}[https://www.rfc-editor.org/rfc/rfc8474.html].
|
|
318
330
|
# * +MAILBOXID+, #data is a string
|
|
319
331
|
#
|
|
332
|
+
# == Extension compatibility
|
|
333
|
+
#
|
|
334
|
+
# Response codes are backwards compatible: Servers are allowed to send new
|
|
335
|
+
# response codes even if the client has not enabled the extension that
|
|
336
|
+
# defines them. When Net::IMAP does not know how to parse response
|
|
337
|
+
# code text, #data returns the unparsed string.
|
|
338
|
+
#
|
|
320
339
|
class ResponseCode < Struct.new(:name, :data)
|
|
321
340
|
##
|
|
322
341
|
# method: name
|
|
@@ -335,10 +354,8 @@ module Net
|
|
|
335
354
|
# code data can take.
|
|
336
355
|
end
|
|
337
356
|
|
|
338
|
-
#
|
|
339
|
-
#
|
|
340
|
-
#
|
|
341
|
-
# Net::IMAP#list returns an array of MailboxList objects.
|
|
357
|
+
# MailboxList represents the data of an untagged +LIST+ response, for a
|
|
358
|
+
# _single_ mailbox path. IMAP#list returns an array of MailboxList objects.
|
|
342
359
|
#
|
|
343
360
|
class MailboxList < Struct.new(:attr, :delim, :name)
|
|
344
361
|
##
|
|
@@ -348,11 +365,11 @@ module Net
|
|
|
348
365
|
# Returns the name attributes. Each name attribute is a symbol capitalized
|
|
349
366
|
# by String#capitalize, such as :Noselect (not :NoSelect). For the
|
|
350
367
|
# semantics of each attribute, see:
|
|
351
|
-
# *
|
|
352
|
-
# *
|
|
353
|
-
# * Net::IMAP@SPECIAL-USE
|
|
368
|
+
# * Net::IMAP@Basic+Mailbox+Attributes
|
|
369
|
+
# * Net::IMAP@Mailbox+role+Attributes
|
|
354
370
|
# * The IANA {IMAP Mailbox Name Attributes
|
|
355
371
|
# registry}[https://www.iana.org/assignments/imap-mailbox-name-attributes/imap-mailbox-name-attributes.xhtml]
|
|
372
|
+
# has links to specifications for all standard mailbox attributes.
|
|
356
373
|
|
|
357
374
|
##
|
|
358
375
|
# method: delim
|
|
@@ -367,17 +384,14 @@ module Net
|
|
|
367
384
|
# Returns the mailbox name.
|
|
368
385
|
end
|
|
369
386
|
|
|
370
|
-
#
|
|
371
|
-
# This object can also be a response to GETQUOTAROOT. In the syntax
|
|
372
|
-
# specification below, the delimiter used with the "#" construct is a
|
|
373
|
-
# single space (SPACE).
|
|
387
|
+
# MailboxQuota represents the data of an untagged +QUOTA+ response.
|
|
374
388
|
#
|
|
375
|
-
#
|
|
389
|
+
# IMAP#getquota returns an array of MailboxQuota objects.
|
|
376
390
|
#
|
|
377
391
|
# Net::IMAP#getquotaroot returns an array containing both MailboxQuotaRoot
|
|
378
392
|
# and MailboxQuota objects.
|
|
379
393
|
#
|
|
380
|
-
#
|
|
394
|
+
# == Required capability
|
|
381
395
|
#
|
|
382
396
|
# Requires +QUOTA+ [RFC2087[https://www.rfc-editor.org/rfc/rfc2087]]
|
|
383
397
|
# or <tt>QUOTA=RES-STORAGE</tt>
|
|
@@ -410,12 +424,14 @@ module Net
|
|
|
410
424
|
#
|
|
411
425
|
end
|
|
412
426
|
|
|
413
|
-
#
|
|
414
|
-
# response. (GETQUOTAROOT can also return Net::IMAP::MailboxQuota.)
|
|
427
|
+
# MailboxQuotaRoot represents the data of an untagged +QUOTAROOT+ response.
|
|
415
428
|
#
|
|
416
|
-
#
|
|
417
|
-
#
|
|
429
|
+
# IMAP#getquotaroot returns an array containing both MailboxQuotaRoot and
|
|
430
|
+
# MailboxQuota objects.
|
|
418
431
|
#
|
|
432
|
+
# == Required capability
|
|
433
|
+
# Requires +QUOTA+ [RFC2087[https://www.rfc-editor.org/rfc/rfc2087]]
|
|
434
|
+
# capability.
|
|
419
435
|
class MailboxQuotaRoot < Struct.new(:mailbox, :quotaroots)
|
|
420
436
|
##
|
|
421
437
|
# method: mailbox
|
|
@@ -430,12 +446,13 @@ module Net
|
|
|
430
446
|
# Zero or more quotaroots that affect the quota on the specified mailbox.
|
|
431
447
|
end
|
|
432
448
|
|
|
433
|
-
#
|
|
449
|
+
# MailboxACLItem represents the data of an untagged +ACL+ response.
|
|
434
450
|
#
|
|
435
|
-
#
|
|
451
|
+
# IMAP#getacl returns an array of MailboxACLItem objects.
|
|
436
452
|
#
|
|
437
|
-
#
|
|
438
|
-
# +ACL+
|
|
453
|
+
# == Required capability
|
|
454
|
+
# Requires +ACL+ [RFC4314[https://www.rfc-editor.org/rfc/rfc4314]]
|
|
455
|
+
# capability.
|
|
439
456
|
class MailboxACLItem < Struct.new(:user, :rights, :mailbox)
|
|
440
457
|
##
|
|
441
458
|
# method: mailbox
|
|
@@ -457,11 +474,12 @@ module Net
|
|
|
457
474
|
# The access rights the indicated #user has to the #mailbox.
|
|
458
475
|
end
|
|
459
476
|
|
|
460
|
-
#
|
|
461
|
-
#
|
|
462
|
-
#
|
|
463
|
-
# Returned by Net::IMAP#namespace, contained inside a Namespaces object.
|
|
477
|
+
# Namespace represents a _single_ namespace, contained inside a Namespaces
|
|
478
|
+
# object.
|
|
464
479
|
#
|
|
480
|
+
# == Required capability
|
|
481
|
+
# Requires either +NAMESPACE+ [RFC2342[https://www.rfc-editor.org/rfc/rfc2342]]
|
|
482
|
+
# or +IMAP4rev2+ capability.
|
|
465
483
|
class Namespace < Struct.new(:prefix, :delim, :extensions)
|
|
466
484
|
##
|
|
467
485
|
# method: prefix
|
|
@@ -483,11 +501,14 @@ module Net
|
|
|
483
501
|
# Extension parameter semantics would be defined by the extension.
|
|
484
502
|
end
|
|
485
503
|
|
|
486
|
-
#
|
|
487
|
-
#
|
|
504
|
+
# Namespaces represents the data of an untagged +NAMESPACE+ response,
|
|
505
|
+
# returned by IMAP#namespace.
|
|
488
506
|
#
|
|
489
|
-
#
|
|
507
|
+
# Contains lists of #personal, #shared, and #other namespaces.
|
|
490
508
|
#
|
|
509
|
+
# == Required capability
|
|
510
|
+
# Requires either +NAMESPACE+ [RFC2342[https://www.rfc-editor.org/rfc/rfc2342]]
|
|
511
|
+
# or +IMAP4rev2+ capability.
|
|
491
512
|
class Namespaces < Struct.new(:personal, :other, :shared)
|
|
492
513
|
##
|
|
493
514
|
# method: personal
|
|
@@ -508,9 +529,9 @@ module Net
|
|
|
508
529
|
# Returns an array of Shared Namespace objects.
|
|
509
530
|
end
|
|
510
531
|
|
|
511
|
-
#
|
|
532
|
+
# StatusData represents the contents of an untagged +STATUS+ response.
|
|
512
533
|
#
|
|
513
|
-
#
|
|
534
|
+
# IMAP#status returns the contents of #attr.
|
|
514
535
|
class StatusData < Struct.new(:mailbox, :attr)
|
|
515
536
|
##
|
|
516
537
|
# method: mailbox
|
|
@@ -531,11 +552,11 @@ module Net
|
|
|
531
552
|
# [Note]
|
|
532
553
|
# When the #sender and #reply_to fields are absent or empty, they will
|
|
533
554
|
# return the same value as #from. Also, fields may return values that are
|
|
534
|
-
# invalid for well-formed [RFC5322[https://
|
|
555
|
+
# invalid for well-formed [RFC5322[https://www.rfc-editor.org/rfc/rfc5322]]
|
|
535
556
|
# messages when the message is malformed or a draft message.
|
|
536
557
|
#
|
|
537
|
-
# See [{IMAP4rev1 §7.4.2}[https://www.rfc-editor.org/rfc/rfc3501
|
|
538
|
-
# and [{IMAP4rev2 §7.5.2}[https://www.rfc-editor.org/rfc/rfc9051
|
|
558
|
+
# See [{IMAP4rev1 §7.4.2}[https://www.rfc-editor.org/rfc/rfc3501#section-7.4.2]]
|
|
559
|
+
# and [{IMAP4rev2 §7.5.2}[https://www.rfc-editor.org/rfc/rfc9051#section-7.5.2]]
|
|
539
560
|
# for full description of the envelope fields, and
|
|
540
561
|
# Net::IMAP@Message+envelope+and+body+structure for other relevant RFCs.
|
|
541
562
|
#
|
|
@@ -549,7 +570,7 @@ module Net
|
|
|
549
570
|
# Returns a string that represents the +Date+ header.
|
|
550
571
|
#
|
|
551
572
|
# [Note]
|
|
552
|
-
# For a well-formed [RFC5322[https://
|
|
573
|
+
# For a well-formed [RFC5322[https://www.rfc-editor.org/rfc/rfc5322]]
|
|
553
574
|
# message, the #date field must not be +nil+. However it can be +nil+
|
|
554
575
|
# for a malformed or draft message.
|
|
555
576
|
|
|
@@ -575,7 +596,7 @@ module Net
|
|
|
575
596
|
# returns +nil+ for this envelope field.
|
|
576
597
|
#
|
|
577
598
|
# [Note]
|
|
578
|
-
# For a well-formed [RFC5322[https://
|
|
599
|
+
# For a well-formed [RFC5322[https://www.rfc-editor.org/rfc/rfc5322]]
|
|
579
600
|
# message, the #from field must not be +nil+. However it can be +nil+
|
|
580
601
|
# for a malformed or draft message.
|
|
581
602
|
|
|
@@ -588,7 +609,7 @@ module Net
|
|
|
588
609
|
# [Note]
|
|
589
610
|
# If the <tt>Sender</tt> header is absent, or is present but empty, the
|
|
590
611
|
# server sets this field to be the same value as #from. Therefore, in a
|
|
591
|
-
# well-formed [RFC5322[https://
|
|
612
|
+
# well-formed [RFC5322[https://www.rfc-editor.org/rfc/rfc5322]] message,
|
|
592
613
|
# the #sender envelope field must not be +nil+. However it can be
|
|
593
614
|
# +nil+ for a malformed or draft message.
|
|
594
615
|
|
|
@@ -602,7 +623,7 @@ module Net
|
|
|
602
623
|
# [Note]
|
|
603
624
|
# If the <tt>Reply-To</tt> header is absent, or is present but empty,
|
|
604
625
|
# the server sets this field to be the same value as #from. Therefore,
|
|
605
|
-
# in a well-formed [RFC5322[https://
|
|
626
|
+
# in a well-formed [RFC5322[https://www.rfc-editor.org/rfc/rfc5322]]
|
|
606
627
|
# message, the #reply_to envelope field must not be +nil+. However it
|
|
607
628
|
# can be +nil+ for a malformed or draft message.
|
|
608
629
|
|
|
@@ -631,7 +652,7 @@ module Net
|
|
|
631
652
|
# Returns a string that represents the <tt>In-Reply-To</tt> header.
|
|
632
653
|
#
|
|
633
654
|
# [Note]
|
|
634
|
-
# For a well-formed [RFC5322[https://
|
|
655
|
+
# For a well-formed [RFC5322[https://www.rfc-editor.org/rfc/rfc5322]]
|
|
635
656
|
# message, the #in_reply_to field, if present, must not be empty. But
|
|
636
657
|
# it can still return an empty string for malformed messages.
|
|
637
658
|
#
|
|
@@ -647,7 +668,7 @@ module Net
|
|
|
647
668
|
# Returns a string that represents the <tt>Message-ID</tt>.
|
|
648
669
|
#
|
|
649
670
|
# [Note]
|
|
650
|
-
# For a well-formed [RFC5322[https://
|
|
671
|
+
# For a well-formed [RFC5322[https://www.rfc-editor.org/rfc/rfc5322]]
|
|
651
672
|
# message, the #message_id field, if present, must not be empty. But it
|
|
652
673
|
# can still return an empty string for malformed messages.
|
|
653
674
|
#
|
|
@@ -661,10 +682,10 @@ module Net
|
|
|
661
682
|
# parsed into its component parts by the server. Address objects are
|
|
662
683
|
# returned within Envelope fields.
|
|
663
684
|
#
|
|
664
|
-
#
|
|
685
|
+
# == Group syntax
|
|
665
686
|
#
|
|
666
687
|
# When the #host field is +nil+, this is a special form of address structure
|
|
667
|
-
# that indicates the [RFC5322[https://
|
|
688
|
+
# that indicates the [RFC5322[https://www.rfc-editor.org/rfc/rfc5322]] group
|
|
668
689
|
# syntax. If the #mailbox name field is also +nil+, this is an end-of-group
|
|
669
690
|
# marker (semicolon in RFC-822 syntax). If the #mailbox name field is
|
|
670
691
|
# non-+NIL+, this is the start of a group marker, and the mailbox #name
|
|
@@ -674,7 +695,7 @@ module Net
|
|
|
674
695
|
# method: name
|
|
675
696
|
# :call-seq: name -> string or nil
|
|
676
697
|
#
|
|
677
|
-
# Returns the [RFC5322[https://
|
|
698
|
+
# Returns the [RFC5322[https://www.rfc-editor.org/rfc/rfc5322]] address
|
|
678
699
|
# +display-name+ (or the mailbox +phrase+ in the RFC-822 grammar).
|
|
679
700
|
|
|
680
701
|
##
|
|
@@ -684,28 +705,28 @@ module Net
|
|
|
684
705
|
# Returns the route from RFC-822 route-addr.
|
|
685
706
|
#
|
|
686
707
|
# Note:: Generating this obsolete route addressing syntax is not allowed
|
|
687
|
-
# by [RFC5322[https://
|
|
708
|
+
# by [RFC5322[https://www.rfc-editor.org/rfc/rfc5322]]. However,
|
|
688
709
|
# addresses with this syntax must still be accepted and parsed.
|
|
689
710
|
|
|
690
711
|
##
|
|
691
712
|
# method: mailbox
|
|
692
713
|
# :call-seq: mailbox -> string or nil
|
|
693
714
|
#
|
|
694
|
-
# Returns the [RFC5322[https://
|
|
715
|
+
# Returns the [RFC5322[https://www.rfc-editor.org/rfc/rfc5322]] address
|
|
695
716
|
# +local-part+, if #host is not +nil+.
|
|
696
717
|
#
|
|
697
718
|
# When #host is +nil+, this returns
|
|
698
|
-
# an [RFC5322[https://
|
|
719
|
+
# an [RFC5322[https://www.rfc-editor.org/rfc/rfc5322]] group name and a +nil+
|
|
699
720
|
# mailbox indicates the end of a group.
|
|
700
721
|
|
|
701
722
|
##
|
|
702
723
|
# method: host
|
|
703
724
|
# :call-seq: host -> string or nil
|
|
704
725
|
#
|
|
705
|
-
# Returns the [RFC5322[https://
|
|
726
|
+
# Returns the [RFC5322[https://www.rfc-editor.org/rfc/rfc5322]] addr-spec
|
|
706
727
|
# +domain+ name.
|
|
707
728
|
#
|
|
708
|
-
# +nil+ indicates [RFC5322[https://
|
|
729
|
+
# +nil+ indicates [RFC5322[https://www.rfc-editor.org/rfc/rfc5322]] group
|
|
709
730
|
# syntax.
|
|
710
731
|
end
|
|
711
732
|
|
|
@@ -717,14 +738,14 @@ module Net
|
|
|
717
738
|
# :call-seq: dsp_type -> string
|
|
718
739
|
#
|
|
719
740
|
# Returns the content disposition type, as defined by
|
|
720
|
-
# [DISPOSITION[https://
|
|
741
|
+
# [DISPOSITION[https://www.rfc-editor.org/rfc/rfc2183]].
|
|
721
742
|
|
|
722
743
|
##
|
|
723
744
|
# method: param
|
|
724
745
|
# :call-seq: param -> hash
|
|
725
746
|
#
|
|
726
747
|
# Returns a hash representing parameters of the Content-Disposition
|
|
727
|
-
# field, as defined by [DISPOSITION[https://
|
|
748
|
+
# field, as defined by [DISPOSITION[https://www.rfc-editor.org/rfc/rfc2183]].
|
|
728
749
|
end
|
|
729
750
|
|
|
730
751
|
# Net::IMAP::ThreadMember represents a thread-node returned
|
|
@@ -763,12 +784,12 @@ module Net
|
|
|
763
784
|
# FetchData#attr value. Although these classes don't share a base class,
|
|
764
785
|
# this module can be used to pattern match all of them.
|
|
765
786
|
#
|
|
766
|
-
# See {[IMAP4rev1] §7.4.2}[https://www.rfc-editor.org/rfc/rfc3501
|
|
767
|
-
# and {[IMAP4rev2] §7.5.2}[https://www.rfc-editor.org/rfc/rfc9051
|
|
787
|
+
# See {[IMAP4rev1] §7.4.2}[https://www.rfc-editor.org/rfc/rfc3501#section-7.4.2]
|
|
788
|
+
# and {[IMAP4rev2] §7.5.2}[https://www.rfc-editor.org/rfc/rfc9051#section-7.5.2-4.9]
|
|
768
789
|
# for full description of all +BODYSTRUCTURE+ fields, and also
|
|
769
790
|
# Net::IMAP@Message+envelope+and+body+structure for other relevant RFCs.
|
|
770
791
|
#
|
|
771
|
-
#
|
|
792
|
+
# == Classes that include BodyStructure
|
|
772
793
|
# BodyTypeBasic:: Represents any message parts that are not handled by
|
|
773
794
|
# BodyTypeText, BodyTypeMessage, or BodyTypeMultipart.
|
|
774
795
|
# BodyTypeText:: Used by <tt>text/*</tt> parts. Contains all of the
|
|
@@ -786,8 +807,8 @@ module Net
|
|
|
786
807
|
# message parts, unless they have a <tt>Content-Type</tt> that is handled by
|
|
787
808
|
# BodyTypeText, BodyTypeMessage, or BodyTypeMultipart.
|
|
788
809
|
#
|
|
789
|
-
# See {[IMAP4rev1] §7.4.2}[https://www.rfc-editor.org/rfc/rfc3501
|
|
790
|
-
# and {[IMAP4rev2] §7.5.2}[https://www.rfc-editor.org/rfc/rfc9051
|
|
810
|
+
# See {[IMAP4rev1] §7.4.2}[https://www.rfc-editor.org/rfc/rfc3501#section-7.4.2]
|
|
811
|
+
# and {[IMAP4rev2] §7.5.2}[https://www.rfc-editor.org/rfc/rfc9051#section-7.5.2-4.9]
|
|
791
812
|
# for full description of all +BODYSTRUCTURE+ fields, and also
|
|
792
813
|
# Net::IMAP@Message+envelope+and+body+structure for other relevant RFCs.
|
|
793
814
|
#
|
|
@@ -804,45 +825,45 @@ module Net
|
|
|
804
825
|
# :call-seq: media_type -> string
|
|
805
826
|
#
|
|
806
827
|
# The top-level media type as defined in
|
|
807
|
-
# [MIME-IMB[https://
|
|
828
|
+
# [MIME-IMB[https://www.rfc-editor.org/rfc/rfc2045]].
|
|
808
829
|
|
|
809
830
|
##
|
|
810
831
|
# method: subtype
|
|
811
832
|
# :call-seq: subtype -> string
|
|
812
833
|
#
|
|
813
834
|
# The media subtype name as defined in
|
|
814
|
-
# [MIME-IMB[https://
|
|
835
|
+
# [MIME-IMB[https://www.rfc-editor.org/rfc/rfc2045]].
|
|
815
836
|
|
|
816
837
|
##
|
|
817
838
|
# method: param
|
|
818
839
|
# :call-seq: param -> string
|
|
819
840
|
#
|
|
820
841
|
# Returns a hash that represents parameters as defined in
|
|
821
|
-
# [MIME-IMB[https://
|
|
842
|
+
# [MIME-IMB[https://www.rfc-editor.org/rfc/rfc2045]].
|
|
822
843
|
|
|
823
844
|
##
|
|
824
845
|
# method: content_id
|
|
825
846
|
# :call-seq: content_id -> string
|
|
826
847
|
#
|
|
827
848
|
# Returns a string giving the content id as defined
|
|
828
|
-
# in [MIME-IMB[https://
|
|
829
|
-
# {§7}[https://
|
|
849
|
+
# in [MIME-IMB[https://www.rfc-editor.org/rfc/rfc2045]]
|
|
850
|
+
# {§7}[https://www.rfc-editor.org/rfc/rfc2045#section-7].
|
|
830
851
|
|
|
831
852
|
##
|
|
832
853
|
# method: description
|
|
833
854
|
# :call-seq: description -> string
|
|
834
855
|
#
|
|
835
856
|
# Returns a string giving the content description as defined
|
|
836
|
-
# in [MIME-IMB[https://
|
|
837
|
-
# {§8}[https://
|
|
857
|
+
# in [MIME-IMB[https://www.rfc-editor.org/rfc/rfc2045]]
|
|
858
|
+
# {§8}[https://www.rfc-editor.org/rfc/rfc2045#section-8].
|
|
838
859
|
|
|
839
860
|
##
|
|
840
861
|
# method: encoding
|
|
841
862
|
# :call-seq: encoding -> string
|
|
842
863
|
#
|
|
843
864
|
# Returns a string giving the content transfer encoding as defined
|
|
844
|
-
# in [MIME-IMB[https://
|
|
845
|
-
# {§6}[https://
|
|
865
|
+
# in [MIME-IMB[https://www.rfc-editor.org/rfc/rfc2045]]
|
|
866
|
+
# {§6}[https://www.rfc-editor.org/rfc/rfc2045#section-6].
|
|
846
867
|
|
|
847
868
|
##
|
|
848
869
|
# method: size
|
|
@@ -855,7 +876,7 @@ module Net
|
|
|
855
876
|
# :call-seq: md5 -> string
|
|
856
877
|
#
|
|
857
878
|
# Returns a string giving the body MD5 value as defined in
|
|
858
|
-
# [MD5[https://
|
|
879
|
+
# [MD5[https://www.rfc-editor.org/rfc/rfc1864]].
|
|
859
880
|
|
|
860
881
|
##
|
|
861
882
|
# method: disposition
|
|
@@ -863,7 +884,7 @@ module Net
|
|
|
863
884
|
#
|
|
864
885
|
# Returns a ContentDisposition object giving the content
|
|
865
886
|
# disposition, as defined by
|
|
866
|
-
# [DISPOSITION[https://
|
|
887
|
+
# [DISPOSITION[https://www.rfc-editor.org/rfc/rfc2183]].
|
|
867
888
|
|
|
868
889
|
##
|
|
869
890
|
# method: language
|
|
@@ -908,7 +929,8 @@ module Net
|
|
|
908
929
|
# for something else?
|
|
909
930
|
#++
|
|
910
931
|
def media_subtype
|
|
911
|
-
warn("media_subtype is obsolete, use subtype instead.\n",
|
|
932
|
+
warn("media_subtype is obsolete, use subtype instead.\n",
|
|
933
|
+
uplevel: 1, category: :deprecated)
|
|
912
934
|
return subtype
|
|
913
935
|
end
|
|
914
936
|
end
|
|
@@ -953,7 +975,8 @@ module Net
|
|
|
953
975
|
# generate a warning message to +stderr+, then return
|
|
954
976
|
# the value of +subtype+.
|
|
955
977
|
def media_subtype
|
|
956
|
-
warn("media_subtype is obsolete, use subtype instead.\n",
|
|
978
|
+
warn("media_subtype is obsolete, use subtype instead.\n",
|
|
979
|
+
uplevel: 1, category: :deprecated)
|
|
957
980
|
return subtype
|
|
958
981
|
end
|
|
959
982
|
end
|
|
@@ -1009,77 +1032,6 @@ module Net
|
|
|
1009
1032
|
end
|
|
1010
1033
|
end
|
|
1011
1034
|
|
|
1012
|
-
# BodyTypeAttachment is not used and will be removed in an upcoming release.
|
|
1013
|
-
#
|
|
1014
|
-
# === Bug Analysis
|
|
1015
|
-
#
|
|
1016
|
-
# \IMAP body structures are parenthesized lists and assign their fields
|
|
1017
|
-
# positionally, so missing fields change the interpretation of all
|
|
1018
|
-
# following fields. Additionally, different body types have a different
|
|
1019
|
-
# number of required fields, followed by optional "extension" fields.
|
|
1020
|
-
#
|
|
1021
|
-
# BodyTypeAttachment was previously returned when a "message/rfc822" part,
|
|
1022
|
-
# which should be sent as <tt>body-type-msg</tt> with ten required fields,
|
|
1023
|
-
# was actually sent as a <tt>body-type-basic</tt> with _seven_ required
|
|
1024
|
-
# fields.
|
|
1025
|
-
#
|
|
1026
|
-
# basic => type, subtype, param, id, desc, enc, octets, md5=nil, dsp=nil, lang=nil, loc=nil, *ext
|
|
1027
|
-
# msg => type, subtype, param, id, desc, enc, octets, envelope, body, lines, md5=nil, ...
|
|
1028
|
-
#
|
|
1029
|
-
# Normally, +envelope+ and +md5+ are incompatible, but Net::IMAP leniently
|
|
1030
|
-
# allowed buggy servers to send +NIL+ for +envelope+. As a result, when a
|
|
1031
|
-
# server sent a <tt>message/rfc822</tt> part with +NIL+ for +md5+ and a
|
|
1032
|
-
# non-<tt>NIL</tt> +dsp+, Net::IMAP misinterpreted the
|
|
1033
|
-
# <tt>Content-Disposition</tt> as if it were a strange body type. In all
|
|
1034
|
-
# reported cases, the <tt>Content-Disposition</tt> was "attachment", so
|
|
1035
|
-
# BodyTypeAttachment was created as the workaround.
|
|
1036
|
-
#
|
|
1037
|
-
# === Current behavior
|
|
1038
|
-
#
|
|
1039
|
-
# When interpreted strictly, +envelope+ and +md5+ are incompatible. So the
|
|
1040
|
-
# current parsing algorithm peeks ahead after it has received the seventh
|
|
1041
|
-
# body field. If the next token is not the start of an +envelope+, we assume
|
|
1042
|
-
# the server has incorrectly sent us a <tt>body-type-basic</tt> and return
|
|
1043
|
-
# BodyTypeBasic. As a result, what was previously BodyTypeMessage#body =>
|
|
1044
|
-
# BodyTypeAttachment is now BodyTypeBasic#disposition => ContentDisposition.
|
|
1045
|
-
#
|
|
1046
|
-
class BodyTypeAttachment < Struct.new(:dsp_type, :_unused_, :param)
|
|
1047
|
-
# *invalid for BodyTypeAttachment*
|
|
1048
|
-
def media_type
|
|
1049
|
-
warn(<<~WARN, uplevel: 1)
|
|
1050
|
-
BodyTypeAttachment#media_type is obsolete. Use dsp_type instead.
|
|
1051
|
-
WARN
|
|
1052
|
-
dsp_type
|
|
1053
|
-
end
|
|
1054
|
-
|
|
1055
|
-
# *invalid for BodyTypeAttachment*
|
|
1056
|
-
def subtype
|
|
1057
|
-
warn("BodyTypeAttachment#subtype is obsolete.\n", uplevel: 1)
|
|
1058
|
-
nil
|
|
1059
|
-
end
|
|
1060
|
-
|
|
1061
|
-
##
|
|
1062
|
-
# method: dsp_type
|
|
1063
|
-
# :call-seq: dsp_type -> string
|
|
1064
|
-
#
|
|
1065
|
-
# Returns the content disposition type, as defined by
|
|
1066
|
-
# [DISPOSITION[https://tools.ietf.org/html/rfc2183]].
|
|
1067
|
-
|
|
1068
|
-
##
|
|
1069
|
-
# method: param
|
|
1070
|
-
# :call-seq: param -> hash
|
|
1071
|
-
#
|
|
1072
|
-
# Returns a hash representing parameters of the Content-Disposition
|
|
1073
|
-
# field, as defined by [DISPOSITION[https://tools.ietf.org/html/rfc2183]].
|
|
1074
|
-
|
|
1075
|
-
##
|
|
1076
|
-
def multipart?
|
|
1077
|
-
return false
|
|
1078
|
-
end
|
|
1079
|
-
end
|
|
1080
|
-
|
|
1081
|
-
deprecate_constant :BodyTypeAttachment
|
|
1082
|
-
|
|
1083
1035
|
# Net::IMAP::BodyTypeMultipart represents body structures of messages and
|
|
1084
1036
|
# message parts, when <tt>Content-Type</tt> is <tt>multipart/*</tt>.
|
|
1085
1037
|
class BodyTypeMultipart < Struct.new(:media_type, :subtype,
|
|
@@ -1100,7 +1052,7 @@ module Net
|
|
|
1100
1052
|
# call-seq: subtype -> string
|
|
1101
1053
|
#
|
|
1102
1054
|
# Returns the content subtype name
|
|
1103
|
-
# as defined in [MIME-IMB[https://
|
|
1055
|
+
# as defined in [MIME-IMB[https://www.rfc-editor.org/rfc/rfc2045]].
|
|
1104
1056
|
|
|
1105
1057
|
##
|
|
1106
1058
|
# method: parts
|
|
@@ -1114,7 +1066,7 @@ module Net
|
|
|
1114
1066
|
# call-seq: param -> hash
|
|
1115
1067
|
#
|
|
1116
1068
|
# Returns a hash that represents parameters
|
|
1117
|
-
# as defined in [MIME-IMB[https://
|
|
1069
|
+
# as defined in [MIME-IMB[https://www.rfc-editor.org/rfc/rfc2045]].
|
|
1118
1070
|
|
|
1119
1071
|
##
|
|
1120
1072
|
# method: disposition
|
|
@@ -1151,29 +1103,11 @@ module Net
|
|
|
1151
1103
|
# generate a warning message to +stderr+, then return
|
|
1152
1104
|
# the value of +subtype+.
|
|
1153
1105
|
def media_subtype
|
|
1154
|
-
warn("media_subtype is obsolete, use subtype instead.\n",
|
|
1106
|
+
warn("media_subtype is obsolete, use subtype instead.\n",
|
|
1107
|
+
uplevel: 1, category: :deprecated)
|
|
1155
1108
|
return subtype
|
|
1156
1109
|
end
|
|
1157
1110
|
end
|
|
1158
1111
|
|
|
1159
|
-
# === Obsolete
|
|
1160
|
-
# BodyTypeExtension is not used and will be removed in an upcoming release.
|
|
1161
|
-
#
|
|
1162
|
-
# >>>
|
|
1163
|
-
# BodyTypeExtension was (incorrectly) used for <tt>message/*</tt> parts
|
|
1164
|
-
# (besides <tt>message/rfc822</tt>, which correctly uses BodyTypeMessage).
|
|
1165
|
-
#
|
|
1166
|
-
# Net::IMAP now (correctly) parses all message types (other than
|
|
1167
|
-
# <tt>message/rfc822</tt> or <tt>message/global</tt>) as BodyTypeBasic.
|
|
1168
|
-
class BodyTypeExtension < Struct.new(:media_type, :subtype,
|
|
1169
|
-
:params, :content_id,
|
|
1170
|
-
:description, :encoding, :size)
|
|
1171
|
-
def multipart?
|
|
1172
|
-
return false
|
|
1173
|
-
end
|
|
1174
|
-
end
|
|
1175
|
-
|
|
1176
|
-
deprecate_constant :BodyTypeExtension
|
|
1177
|
-
|
|
1178
1112
|
end
|
|
1179
1113
|
end
|