net-imap 0.2.3 → 0.3.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/dependabot.yml +6 -0
- data/.github/workflows/test.yml +2 -2
- data/.gitignore +1 -0
- data/Gemfile +3 -0
- data/LICENSE.txt +62 -0
- data/README.md +1 -2
- data/Rakefile +3 -0
- data/benchmarks/stringprep.yml +65 -0
- data/benchmarks/table-regexps.yml +39 -0
- data/docs/styles.css +36 -0
- data/lib/net/imap/authenticators/cram_md5.rb +5 -3
- data/lib/net/imap/authenticators/digest_md5.rb +11 -7
- data/lib/net/imap/authenticators/login.rb +4 -1
- data/lib/net/imap/authenticators/xoauth2.rb +20 -0
- data/lib/net/imap/authenticators.rb +41 -17
- data/lib/net/imap/command_data.rb +8 -11
- data/lib/net/imap/data_encoding.rb +101 -5
- data/lib/net/imap/errors.rb +1 -1
- data/lib/net/imap/flags.rb +105 -77
- data/lib/net/imap/response_data.rb +1077 -317
- data/lib/net/imap/response_parser.rb +66 -1
- data/lib/net/imap/sasl/saslprep.rb +55 -0
- data/lib/net/imap/sasl/saslprep_tables.rb +98 -0
- data/lib/net/imap/sasl/stringprep.rb +72 -0
- data/lib/net/imap/sasl/stringprep_tables.rb +153 -0
- data/lib/net/imap/sasl.rb +78 -0
- data/lib/net/imap.rb +1209 -283
- data/net-imap.gemspec +6 -4
- data/rakelib/rdoc.rake +70 -0
- data/rakelib/rfcs.rake +168 -0
- data/rakelib/saslprep.rake +30 -0
- data/rakelib/string_prep_tables_generator.rb +423 -0
- metadata +34 -4
data/lib/net/imap/flags.rb
CHANGED
@@ -4,26 +4,28 @@ module Net
|
|
4
4
|
class IMAP < Protocol
|
5
5
|
|
6
6
|
# -------------------------------------------------------------------------
|
7
|
-
# :section:
|
7
|
+
# :section: System Flags
|
8
8
|
#
|
9
9
|
# A message has a list of zero or more named tokens, known as "flags",
|
10
10
|
# associated with it. A flag is set by its addition to this list and is
|
11
|
-
# cleared by its removal. There are two types of flags in
|
12
|
-
#
|
13
|
-
#
|
11
|
+
# cleared by its removal. There are two types of flags in
|
12
|
+
# IMAP4rev1[https://www.rfc-editor.org/rfc/rfc3501.html] and
|
13
|
+
# IMAP4rev2[https://www.rfc-editor.org/rfc/rfc9051.html]: flags and
|
14
|
+
# keywords. A flag of either type can be permanent or session-only.
|
14
15
|
#
|
15
|
-
# A "system flag" is a message flag name that is predefined in the IMAP
|
16
|
-
#
|
17
|
-
# as symbols, without the "\" prefix.
|
16
|
+
# A "system flag" is a message flag name that is predefined in the \IMAP
|
17
|
+
# specifications and begins with <tt>"\"</tt>. Net::IMAP returns all
|
18
|
+
# system flags as symbols, without the <tt>"\"</tt> prefix.
|
18
19
|
#
|
19
|
-
# The descriptions here were copied from
|
20
|
-
#
|
21
|
-
#
|
22
|
-
#
|
23
|
-
#
|
24
|
-
#
|
20
|
+
# <em>The descriptions here were copied from</em> {[RFC-9051
|
21
|
+
# §2.3.2]}[https://www.rfc-editor.org/rfc/rfc9051.html#section-2.3.2].
|
22
|
+
# <em>See also</em> {[RFC-3501
|
23
|
+
# §2.3.2]}[https://www.rfc-editor.org/rfc/rfc3501.html#section-2.3.2],
|
24
|
+
# <em>which describes the flags message attribute semantics under</em>
|
25
|
+
# IMAP4rev1[https://www.rfc-editor.org/rfc/rfc3501.html].
|
25
26
|
# -------------------------------------------------------------------------
|
26
27
|
|
28
|
+
##
|
27
29
|
# Flag indicating a message has been read.
|
28
30
|
SEEN = :Seen
|
29
31
|
|
@@ -52,30 +54,37 @@ module Net
|
|
52
54
|
# of this message.
|
53
55
|
#
|
54
56
|
# This flag was defined by
|
55
|
-
# IMAP4rev1
|
56
|
-
# and
|
57
|
-
# IMAP4rev2
|
57
|
+
# IMAP4rev1[https://www.rfc-editor.org/rfc/rfc3501.html]
|
58
|
+
# and is deprecated by
|
59
|
+
# IMAP4rev2[https://www.rfc-editor.org/rfc/rfc9051.html].
|
58
60
|
RECENT = :Recent
|
59
61
|
|
60
62
|
# -------------------------------------------------------------------------
|
61
|
-
# :section: Mailbox
|
62
|
-
# Mailbox name attributes will be returned in
|
63
|
+
# :section: Basic Mailbox Attributes
|
64
|
+
# Mailbox name attributes will be returned in #list responses. Base
|
63
65
|
# attributes must be returned according to the server's capabilities.
|
64
66
|
#
|
65
67
|
# IMAP4 specifies that all mailbox name attributes, including future
|
66
|
-
# extensions, begin with "\"
|
67
|
-
# symbols, without the "\" prefix.
|
68
|
+
# extensions, begin with <tt>"\"</tt>. Net::IMAP returns all mailbox
|
69
|
+
# attributes as symbols, without the <tt>"\"</tt> prefix.
|
70
|
+
#
|
71
|
+
# Mailbox name attributes are not case-sensitive. <em>The current
|
72
|
+
# implementation</em> normalizes mailbox attribute case using
|
73
|
+
# String#capitalize, such as +:Noselect+ (not +:NoSelect+). The constants
|
74
|
+
# (such as NO_SELECT) can also be used for comparison. The contants have
|
75
|
+
# been defined both with and without underscores between words.
|
68
76
|
#
|
69
|
-
# The descriptions here were copied from
|
70
|
-
#
|
77
|
+
# <em>The descriptions here were copied from</em> {[RFC-9051 §
|
78
|
+
# 7.3.1]}[https://www.rfc-editor.org/rfc/rfc9051.html#section-7.3.1].
|
71
79
|
#
|
72
|
-
# Other mailbox name attributes can be found in the
|
73
|
-
# Attributes registry
|
80
|
+
# Other mailbox name attributes can be found in the {IANA IMAP Mailbox Name
|
81
|
+
# Attributes registry}[https://www.iana.org/assignments/imap-mailbox-name-attributes/imap-mailbox-name-attributes.xhtml].
|
74
82
|
# -------------------------------------------------------------------------
|
75
83
|
|
76
|
-
|
84
|
+
##
|
85
|
+
# The +\NonExistent+ attribute indicates that a mailbox name does not refer
|
77
86
|
# to an existing mailbox. Note that this attribute is not meaningful by
|
78
|
-
# itself, as mailbox names that match the canonical
|
87
|
+
# itself, as mailbox names that match the canonical #list pattern but don't
|
79
88
|
# exist must not be returned unless one of the two conditions listed below
|
80
89
|
# is also satisfied:
|
81
90
|
#
|
@@ -84,91 +93,103 @@ module Net
|
|
84
93
|
# specified).
|
85
94
|
#
|
86
95
|
# 2. "RECURSIVEMATCH" has been specified, and the mailbox name has at least
|
87
|
-
# one descendant mailbox name that does not match the
|
96
|
+
# one descendant mailbox name that does not match the #list pattern and
|
88
97
|
# does match the selection criteria.
|
89
98
|
#
|
90
|
-
# In practice, this means that the
|
91
|
-
# returned with one or more of
|
99
|
+
# In practice, this means that the +\NonExistent+ attribute is usually
|
100
|
+
# returned with one or more of +\Subscribed+, +\Remote+, +\HasChildren+, or
|
92
101
|
# the CHILDINFO extended data item.
|
93
102
|
#
|
94
|
-
# The client must treat the presence of the
|
95
|
-
#
|
96
|
-
NONEXISTENT = :
|
103
|
+
# The client must treat the presence of the +\NonExistent+ attribute as if the
|
104
|
+
# +\NoSelect+ attribute was also sent by the server
|
105
|
+
NONEXISTENT = :Nonexistent
|
97
106
|
|
98
107
|
# Mailbox attribute indicating it is not possible for any child levels of
|
99
108
|
# hierarchy to exist under this name; no child levels exist now and none can
|
100
109
|
# be created in the future children.
|
101
110
|
#
|
102
|
-
# The client must treat the presence of the
|
103
|
-
#
|
104
|
-
|
111
|
+
# The client must treat the presence of the +\NoInferiors+ attribute as if the
|
112
|
+
# +\HasNoChildren+ attribute was also sent by the server
|
113
|
+
NO_INFERIORS = :Noinferiors
|
105
114
|
|
106
115
|
# Mailbox attribute indicating it is not possible to use this name as a
|
107
116
|
# selectable mailbox.
|
108
|
-
|
117
|
+
NO_SELECT = :Noselect
|
109
118
|
|
110
119
|
# The presence of this attribute indicates that the mailbox has child
|
111
120
|
# mailboxes. A server SHOULD NOT set this attribute if there are child
|
112
121
|
# mailboxes and the user does not have permission to access any of them. In
|
113
|
-
# this case,
|
114
|
-
# may not be able to efficiently compute whether a user has access to
|
115
|
-
# child mailboxes. Note that even though the
|
116
|
-
# mailbox must be correct at the time of processing the mailbox, a
|
117
|
-
# must be prepared to deal with a situation when a mailbox is marked
|
118
|
-
# the
|
119
|
-
# to the
|
122
|
+
# this case, +\HasNoChildren+ SHOULD be used. In many cases, however, a
|
123
|
+
# server may not be able to efficiently compute whether a user has access to
|
124
|
+
# any child mailboxes. Note that even though the +\HasChildren+ attribute
|
125
|
+
# for a mailbox must be correct at the time of processing the mailbox, a
|
126
|
+
# client must be prepared to deal with a situation when a mailbox is marked
|
127
|
+
# with the +\HasChildren+ attribute, but no child mailbox appears in the
|
128
|
+
# response to the #list command. This might happen, for example, due to child
|
120
129
|
# mailboxes being deleted or made inaccessible to the user (using access
|
121
130
|
# control) by another client before the server is able to list them.
|
122
131
|
#
|
123
|
-
# It is an error for the server to return both a
|
124
|
-
#
|
125
|
-
# encounters a
|
126
|
-
# attributes present should act as if both are absent in the
|
127
|
-
HAS_CHILDREN = :
|
132
|
+
# It is an error for the server to return both a +\HasChildren+ and a
|
133
|
+
# +\HasNoChildren+ attribute in the same #list response. A client that
|
134
|
+
# encounters a #list response with both +\HasChildren+ and +\HasNoChildren+
|
135
|
+
# attributes present should act as if both are absent in the #list response.
|
136
|
+
HAS_CHILDREN = :Haschildren
|
128
137
|
|
129
138
|
# The presence of this attribute indicates that the mailbox has NO child
|
130
139
|
# mailboxes that are accessible to the currently authenticated user.
|
131
140
|
#
|
132
|
-
# It is an error for the server to return both a
|
133
|
-
#
|
134
|
-
# encounters a
|
135
|
-
# attributes present should act as if both are absent in the
|
141
|
+
# It is an error for the server to return both a +\HasChildren+ and a
|
142
|
+
# +\HasNoChildren+ attribute in the same #list response. A client that
|
143
|
+
# encounters a #list response with both +\HasChildren+ and +\HasNoChildren+
|
144
|
+
# attributes present should act as if both are absent in the #list response.
|
136
145
|
#
|
137
|
-
# Note: the
|
138
|
-
#
|
139
|
-
# and none can be created in the future.
|
140
|
-
HAS_NO_CHILDREN = :
|
146
|
+
# Note: the +\HasNoChildren+ attribute should not be confused with the
|
147
|
+
# +\NoInferiors+ attribute, which indicates that no child mailboxes exist
|
148
|
+
# now and none can be created in the future.
|
149
|
+
HAS_NO_CHILDREN = :Hasnochildren
|
141
150
|
|
142
151
|
# The mailbox has been marked "interesting" by the server; the mailbox
|
143
152
|
# probably contains messages that have been added since the last time the
|
144
153
|
# mailbox was selected.
|
145
154
|
#
|
146
155
|
# If it is not feasible for the server to determine whether or not the
|
147
|
-
# mailbox is "interesting", the server SHOULD NOT send either
|
148
|
-
#
|
149
|
-
# and
|
156
|
+
# mailbox is "interesting", the server SHOULD NOT send either +\Marked+ or
|
157
|
+
# +\Unmarked+. The server MUST NOT send more than one of +\Marked+,
|
158
|
+
# +\Unmarked+, and +\NoSelect+ for a single mailbox, and it MAY send none of
|
159
|
+
# these.
|
150
160
|
MARKED = :Marked
|
151
161
|
|
152
162
|
# The mailbox does not contain any additional messages since the last time
|
153
163
|
# the mailbox was selected.
|
154
164
|
#
|
155
165
|
# If it is not feasible for the server to determine whether or not the
|
156
|
-
# mailbox is "interesting", the server SHOULD NOT send either
|
157
|
-
#
|
158
|
-
# and
|
166
|
+
# mailbox is "interesting", the server SHOULD NOT send either +\Marked+ or
|
167
|
+
# +\Unmarked+. The server MUST NOT send more than one of +\Marked+,
|
168
|
+
# +\Unmarked+, and +\NoSelect+ for a single mailbox, and it MAY send none of
|
169
|
+
# these.
|
159
170
|
UNMARKED = :Unmarked
|
160
171
|
|
161
|
-
# The mailbox name was subscribed to using the
|
172
|
+
# The mailbox name was subscribed to using the #subscribe command.
|
162
173
|
SUBSCRIBED = :Subscribed
|
163
174
|
|
164
175
|
# The mailbox is a remote mailbox.
|
165
176
|
REMOTE = :Remove
|
166
177
|
|
178
|
+
# Alias for NO_INFERIORS, to match the \IMAP spelling.
|
179
|
+
NOINFERIORS = NO_INFERIORS
|
180
|
+
# Alias for NO_SELECT, to match the \IMAP spelling.
|
181
|
+
NOSELECT = NO_SELECT
|
182
|
+
# Alias for HAS_CHILDREN, to match the \IMAP spelling.
|
183
|
+
HASCHILDREN = HAS_CHILDREN
|
184
|
+
# Alias for HAS_NO_CHILDREN, to match the \IMAP spelling.
|
185
|
+
HASNOCHILDREN = HAS_NO_CHILDREN
|
186
|
+
|
167
187
|
# -------------------------------------------------------------------------
|
168
|
-
# :section: Mailbox
|
169
|
-
#
|
170
|
-
#
|
171
|
-
#
|
188
|
+
# :section: Mailbox role attributes
|
189
|
+
#
|
190
|
+
# Mailbox name attributes will be returned in #list responses. In addition
|
191
|
+
# to the base mailbox name attributes defined above, an \IMAP server MAY
|
192
|
+
# also include any or all of the following attributes that denote "role" (or
|
172
193
|
# "special-use") of a mailbox. These attributes are included along with base
|
173
194
|
# attributes defined above. A given mailbox may have none, one, or more than
|
174
195
|
# one of these attributes. In some cases, a special use is advice to a
|
@@ -176,14 +197,18 @@ module Net
|
|
176
197
|
# client about what to expect to find there.
|
177
198
|
#
|
178
199
|
# IMAP4 specifies that all mailbox name attributes, including future
|
179
|
-
# extensions, begin with "\"
|
180
|
-
# symbols, without the "\" prefix.
|
200
|
+
# extensions, begin with <tt>"\"</tt>. Net::IMAP returns all mailbox
|
201
|
+
# attributes as symbols, without the <tt>"\"</tt> prefix.
|
202
|
+
#
|
203
|
+
# The special use attributes were first defined as part of the
|
204
|
+
# SPECIAL-USE[https://www.rfc-editor.org/rfc/rfc6154.html] extension, but
|
205
|
+
# servers may return them without including the +SPECIAL-USE+ #capability.
|
181
206
|
#
|
182
|
-
# The descriptions here were copied from
|
183
|
-
#
|
207
|
+
# <em>The descriptions here were copied from</em> {[RFC-9051 §
|
208
|
+
# 7.3.1]}[https://www.rfc-editor.org/rfc/rfc9051.html#section-7.3.1].
|
184
209
|
#
|
185
|
-
# Other mailbox name attributes can be found in the
|
186
|
-
# Attributes registry
|
210
|
+
# Other mailbox name attributes can be found in the {IANA IMAP Mailbox Name
|
211
|
+
# Attributes registry}[https://www.iana.org/assignments/imap-mailbox-name-attributes/imap-mailbox-name-attributes.xhtml].
|
187
212
|
# -------------------------------------------------------------------------
|
188
213
|
|
189
214
|
# Mailbox attribute indicating that this mailbox presents all messages in
|
@@ -206,7 +231,9 @@ module Net
|
|
206
231
|
# client put drafts here
|
207
232
|
DRAFTS = :Drafts
|
208
233
|
|
209
|
-
|
234
|
+
#--
|
235
|
+
# n.b. FLAGGED is defined in the system flags section.
|
236
|
+
#++
|
210
237
|
|
211
238
|
# Mailbox attribute indicating that this mailbox is where messages deemed to
|
212
239
|
# be junk mail are held. Some server implementations might put messages here
|
@@ -223,12 +250,13 @@ module Net
|
|
223
250
|
# Mailbox attribute indicating that this mailbox is used to hold messages
|
224
251
|
# that have been deleted or marked for deletion. In some server
|
225
252
|
# implementations, this might be a virtual mailbox, containing messages from
|
226
|
-
# other mailboxes that are marked with the
|
253
|
+
# other mailboxes that are marked with the +\Deleted+ message flag.
|
227
254
|
# Alternatively, this might just be advice that a client that chooses not to
|
228
|
-
# use the IMAP
|
229
|
-
# implementations that strictly expect the IMAP
|
255
|
+
# use the \IMAP +\Deleted+ model should use as its trash location. In server
|
256
|
+
# implementations that strictly expect the \IMAP +\Deleted+ model, this
|
230
257
|
# special use is likely not to be supported.
|
231
258
|
TRASH = :Trash
|
232
259
|
|
260
|
+
# :section:
|
233
261
|
end
|
234
262
|
end
|