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