Skip to content

Commit 011063d

Browse files
server: error when selecting should unselect
Closes: #351
1 parent 3bc38e3 commit 011063d

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

server/cmd_auth.go

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,20 @@ type Select struct {
2020

2121
func (cmd *Select) Handle(conn Conn) error {
2222
ctx := conn.Context()
23+
24+
// As per RFC1730#6.3.1,
25+
// The SELECT command automatically deselects any
26+
// currently selected mailbox before attempting the new selection.
27+
// Consequently, if a mailbox is selected and a SELECT command that
28+
// fails is attempted, no mailbox is selected.
29+
// For example, some clients (e.g. Apple Mail) perform SELECT "" when the
30+
// server doesn't announce the UNSELECT capability.
31+
ctx.Mailbox = nil
32+
ctx.MailboxReadOnly = false
33+
2334
if ctx.User == nil {
2435
return ErrNotAuthenticated
2536
}
26-
2737
mbox, err := ctx.User.GetMailbox(cmd.Mailbox)
2838
if err != nil {
2939
return err
@@ -149,7 +159,7 @@ func (cmd *List) Handle(conn Conn) error {
149159
go (func() {
150160
done <- conn.WriteResp(res)
151161
// Make sure to drain the channel.
152-
for _ = range ch {
162+
for range ch {
153163
}
154164
})()
155165

0 commit comments

Comments
 (0)