Skip to content

Commit 5c61dfb

Browse files
committed
🐛 Fix incorrectly capitalized mailbox attrs
Now the constants match Net::IMAP's behavior, so they can be used for comparison. Also add docs and aliases for flag and mailbox attrs. Because the consts are ALL_CAPS, it's nicer to use underscore versions.
1 parent 7ea3609 commit 5c61dfb

File tree

1 file changed

+23
-5
lines changed

1 file changed

+23
-5
lines changed

lib/net/imap/flags.rb

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,11 @@ class IMAP < Protocol
6868
# extensions, begin with <tt>"\"</tt>. Net::IMAP returns all mailbox
6969
# attributes as symbols, without the <tt>"\"</tt> prefix.
7070
#
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.
7176
#
7277
# <em>The descriptions here were copied from</em> {[RFC-9051 §
7378
# 7.3.1]}[https://www.rfc-editor.org/rfc/rfc9051.html#section-7.3.1].
@@ -97,19 +102,19 @@ class IMAP < Protocol
97102
#
98103
# The client must treat the presence of the +\NonExistent+ attribute as if the
99104
# +\NoSelect+ attribute was also sent by the server
100-
NONEXISTENT = :NonExistent
105+
NONEXISTENT = :Nonexistent
101106

102107
# Mailbox attribute indicating it is not possible for any child levels of
103108
# hierarchy to exist under this name; no child levels exist now and none can
104109
# be created in the future children.
105110
#
106111
# The client must treat the presence of the +\NoInferiors+ attribute as if the
107112
# +\HasNoChildren+ attribute was also sent by the server
108-
NOINFERIORS = :Noinferiors
113+
NO_INFERIORS = :Noinferiors
109114

110115
# Mailbox attribute indicating it is not possible to use this name as a
111116
# selectable mailbox.
112-
NOSELECT = :Noselect
117+
NO_SELECT = :Noselect
113118

114119
# The presence of this attribute indicates that the mailbox has child
115120
# mailboxes. A server SHOULD NOT set this attribute if there are child
@@ -128,7 +133,7 @@ class IMAP < Protocol
128133
# +\HasNoChildren+ attribute in the same #list response. A client that
129134
# encounters a #list response with both +\HasChildren+ and +\HasNoChildren+
130135
# attributes present should act as if both are absent in the #list response.
131-
HAS_CHILDREN = :HasChildren
136+
HAS_CHILDREN = :Haschildren
132137

133138
# The presence of this attribute indicates that the mailbox has NO child
134139
# mailboxes that are accessible to the currently authenticated user.
@@ -141,7 +146,7 @@ class IMAP < Protocol
141146
# Note: the +\HasNoChildren+ attribute should not be confused with the
142147
# +\NoInferiors+ attribute, which indicates that no child mailboxes exist
143148
# now and none can be created in the future.
144-
HAS_NO_CHILDREN = :HasNoChildren
149+
HAS_NO_CHILDREN = :Hasnochildren
145150

146151
# The mailbox has been marked "interesting" by the server; the mailbox
147152
# probably contains messages that have been added since the last time the
@@ -170,6 +175,15 @@ class IMAP < Protocol
170175
# The mailbox is a remote mailbox.
171176
REMOTE = :Remove
172177

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+
173187
# -------------------------------------------------------------------------
174188
# :section: Mailbox role attributes
175189
#
@@ -186,6 +200,10 @@ class IMAP < Protocol
186200
# extensions, begin with <tt>"\"</tt>. Net::IMAP returns all mailbox
187201
# attributes as symbols, without the <tt>"\"</tt> prefix.
188202
#
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.
206+
#
189207
# <em>The descriptions here were copied from</em> {[RFC-9051 §
190208
# 7.3.1]}[https://www.rfc-editor.org/rfc/rfc9051.html#section-7.3.1].
191209
#

0 commit comments

Comments
 (0)