From 55febe304e3cb6bfc64a9af8e890dd7d09398c65 Mon Sep 17 00:00:00 2001 From: Mechiel Lukkien Date: Sat, 23 Sep 2023 21:00:26 +0200 Subject: [PATCH] imapserver: always send special-use attributes for mailboxes even if not asked for with the "return (special-use)" extended list parameter. macos x mail does not request the special-use flags, but will use them when present. for issue #66, thanks x8x for providing the imap protocol transcript that showed how it is done! --- imapserver/list.go | 7 ++++--- imapserver/list_test.go | 6 +++--- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/imapserver/list.go b/imapserver/list.go index ed8ffa2f98..7bdebd6fc7 100644 --- a/imapserver/list.go +++ b/imapserver/list.go @@ -58,7 +58,7 @@ func (c *conn) cmdList(tag, cmd string, p *parser) { p.xspace() patterns, isList := p.xmboxOrPat() isExtended = isExtended || isList - var retSubscribed, retChildren, retSpecialUse bool + var retSubscribed, retChildren bool var retStatusAttrs []string if p.take(" RETURN (") { isExtended = true @@ -79,7 +79,8 @@ func (c *conn) cmdList(tag, cmd string, p *parser) { retChildren = true case "SPECIAL-USE": // ../rfc/6154:478 - retSpecialUse = true + // We always include special-use mailbox flags. Mac OS X Mail 16.0 (sept 2023) does + // not ask for the flags, but does use them when given. ../rfc/6154:146 case "STATUS": // ../rfc/9051:7072 ../rfc/5819:181 p.xspace() @@ -189,7 +190,7 @@ func (c *conn) cmdList(tag, cmd string, p *parser) { if !listSubscribed && retSubscribed && info.subscribed { flags = append(flags, bare(`\Subscribed`)) } - if retSpecialUse && info.mailbox != nil { + if info.mailbox != nil { if info.mailbox.Archive { flags = append(flags, bare(`\Archive`)) } diff --git a/imapserver/list_test.go b/imapserver/list_test.go index 49d81a8cd6..72fd1c1099 100644 --- a/imapserver/list_test.go +++ b/imapserver/list_test.go @@ -27,13 +27,13 @@ func TestListBasic(t *testing.T) { tc.xuntagged(ulist("Inbox")) tc.last(tc.client.List("%")) - tc.xuntagged(ulist("Archive"), ulist("Drafts"), ulist("Inbox"), ulist("Junk"), ulist("Sent"), ulist("Trash")) + tc.xuntagged(ulist("Archive", `\Archive`), ulist("Drafts", `\Drafts`), ulist("Inbox"), ulist("Junk", `\Junk`), ulist("Sent", `\Sent`), ulist("Trash", `\Trash`)) tc.last(tc.client.List("*")) - tc.xuntagged(ulist("Archive"), ulist("Drafts"), ulist("Inbox"), ulist("Junk"), ulist("Sent"), ulist("Trash")) + tc.xuntagged(ulist("Archive", `\Archive`), ulist("Drafts", `\Drafts`), ulist("Inbox"), ulist("Junk", `\Junk`), ulist("Sent", `\Sent`), ulist("Trash", `\Trash`)) tc.last(tc.client.List("A*")) - tc.xuntagged(ulist("Archive")) + tc.xuntagged(ulist("Archive", `\Archive`)) tc.client.Create("Inbox/todo")