duesee / imap-codec

Rock-solid and complete codec for IMAP
Apache License 2.0
35 stars 13 forks source link

fix: Representation of `Mailbox` #371

Closed duesee closed 5 months ago

duesee commented 9 months ago

Currently, we have ...

enum Mailbox {
    Inbox,
    Other(...),
}

Question: What is INBOX.FOO?

Answer: It depends.

It could be a single folder INBOX.FOO that is not a subfolder of INBOX. But when the hierarchy separator of the IMAP server is ., FOO should (arguably) be a subfolder of INBOX. Thus, when . is a hierarchy seperator, inbox.FOO, inboX.FOO, ..., INBOX.FOO should all reference the same folder?

This means: The interpretation of a folder depends on the hierarchy delimiter.

Do we need ...

struct Mailbox {
    hierarchy_delimiter: Delimiter,
    data: MailboxPath,
}

enum MailboxPath {
    Inbox(Path),
    Other(Path), // Must not start with INBOX
}

... instead?

TODO

duesee commented 8 months ago

From (now offline 😢) imap-protocol mailing list:

On Wed, 30 Nov 2005, Ingo Schurr wrote:

Reading the BNF as pedantic as possible, neither DQUOTE "Inbox" DQUOTE nor "Inbox/foo" would trigger the INBOX magic, as both would be astrings. (In the example '/' would be a hierarchical separator)

The first is not the case. INBOX in a mailbox name is always INBOX, even if it is given as a string. Note the following in the text of that BNF rule: ; An astring which consists of ; the case-insensitive sequence "I" "N" "B" "O" "X" ; is considered to be INBOX and not an astring.

The second is the case. There is no reason to believe that Inbox/foo is in any way related to INBOX. That's completely server-dependent.

For what it's worth, UW imapd won't prevent you from creating Inbox/foo however it will hide the Inbox/ directory and you can't see it (not even with a wildcard) unless Inbox/ is in the pattern: C: 1 create Inbox/foo S: 1 OK CREATE completed C: 2 list "" Inbox S: LIST (\NoInferiors) NIL INBOX S: 2 OK LIST completed C: 3 list "" Inbox/ S: LIST (\NoSelect) "/" Inbox/ S: LIST (\NoInferiors \UnMarked) "/" Inbox/foo S: 3 OK LIST completed

-- Mark --

duesee commented 5 months ago

I think there is nothing we should do here.