From 0b18d23e95af67255576c1752379ce1ae2fff669 Mon Sep 17 00:00:00 2001 From: nick evans Date: Fri, 11 Nov 2022 16:39:00 -0500 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Fix=20incorrectly=20capitalized?= =?UTF-8?q?=20mailbox=20attrs?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- lib/net/imap/flags.rb | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/lib/net/imap/flags.rb b/lib/net/imap/flags.rb index a604f4d0..68bb8b81 100644 --- a/lib/net/imap/flags.rb +++ b/lib/net/imap/flags.rb @@ -68,6 +68,11 @@ class IMAP < Protocol # extensions, begin with "\". Net::IMAP returns all mailbox # attributes as symbols, without the "\" prefix. # + # Mailbox name attributes are not case-sensitive. The current + # implementation normalizes mailbox attribute case using + # String#capitalize, such as +:Noselect+ (not +:NoSelect+). The constants + # (such as NO_SELECT) can also be used for comparison. The contants have + # been defined both with and without underscores between words. # # The descriptions here were copied from {[RFC-9051 § # 7.3.1]}[https://www.rfc-editor.org/rfc/rfc9051.html#section-7.3.1]. @@ -97,7 +102,7 @@ class IMAP < Protocol # # The client must treat the presence of the +\NonExistent+ attribute as if the # +\NoSelect+ attribute was also sent by the server - NONEXISTENT = :NonExistent + NONEXISTENT = :Nonexistent # Mailbox attribute indicating it is not possible for any child levels of # hierarchy to exist under this name; no child levels exist now and none can @@ -105,11 +110,11 @@ class IMAP < Protocol # # The client must treat the presence of the +\NoInferiors+ attribute as if the # +\HasNoChildren+ attribute was also sent by the server - NOINFERIORS = :Noinferiors + NO_INFERIORS = :Noinferiors # Mailbox attribute indicating it is not possible to use this name as a # selectable mailbox. - NOSELECT = :Noselect + NO_SELECT = :Noselect # The presence of this attribute indicates that the mailbox has child # mailboxes. A server SHOULD NOT set this attribute if there are child @@ -128,7 +133,7 @@ class IMAP < Protocol # +\HasNoChildren+ attribute in the same #list response. A client that # encounters a #list response with both +\HasChildren+ and +\HasNoChildren+ # attributes present should act as if both are absent in the #list response. - HAS_CHILDREN = :HasChildren + HAS_CHILDREN = :Haschildren # The presence of this attribute indicates that the mailbox has NO child # mailboxes that are accessible to the currently authenticated user. @@ -141,7 +146,7 @@ class IMAP < Protocol # Note: the +\HasNoChildren+ attribute should not be confused with the # +\NoInferiors+ attribute, which indicates that no child mailboxes exist # now and none can be created in the future. - HAS_NO_CHILDREN = :HasNoChildren + HAS_NO_CHILDREN = :Hasnochildren # The mailbox has been marked "interesting" by the server; the mailbox # probably contains messages that have been added since the last time the @@ -170,6 +175,15 @@ class IMAP < Protocol # The mailbox is a remote mailbox. REMOTE = :Remove + # Alias for NO_INFERIORS, to match the \IMAP spelling. + NOINFERIORS = NO_INFERIORS + # Alias for NO_SELECT, to match the \IMAP spelling. + NOSELECT = NO_SELECT + # Alias for HAS_CHILDREN, to match the \IMAP spelling. + HASCHILDREN = HAS_CHILDREN + # Alias for HAS_NO_CHILDREN, to match the \IMAP spelling. + HASNOCHILDREN = HAS_NO_CHILDREN + # ------------------------------------------------------------------------- # :section: Mailbox role attributes # @@ -186,6 +200,10 @@ class IMAP < Protocol # extensions, begin with "\". Net::IMAP returns all mailbox # attributes as symbols, without the "\" prefix. # + # The special use attributes were first defined as part of the + # SPECIAL-USE[https://www.rfc-editor.org/rfc/rfc6154.html] extension, but + # servers may return them without including the +SPECIAL-USE+ #capability. + # # The descriptions here were copied from {[RFC-9051 § # 7.3.1]}[https://www.rfc-editor.org/rfc/rfc9051.html#section-7.3.1]. #