Skip to content

Commit 00c73ea

Browse files
committed
Handle STORE FLAGS A B syntax
See emersion#243 (comment).
1 parent 83a1a4e commit 00c73ea

File tree

2 files changed

+23
-2
lines changed

2 files changed

+23
-2
lines changed

commands/store.go

+5-2
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,10 @@ func (cmd *Store) Parse(fields []interface{}) error {
4141
cmd.Item = imap.StoreItem(strings.ToUpper(item))
4242
}
4343

44-
// TODO: could be fields[2:] according to RFC 3501 page 91 "store-att-flags"
45-
cmd.Value = fields[2]
44+
if len(fields[2:]) == 1 {
45+
cmd.Value = fields[2]
46+
} else {
47+
cmd.Value = fields[2:]
48+
}
4649
return nil
4750
}

server/cmd_selected_test.go

+18
Original file line numberDiff line numberDiff line change
@@ -369,6 +369,24 @@ func TestStore_InvalidFlags(t *testing.T) {
369369
}
370370
}
371371

372+
func TestStore_NonList(t *testing.T) {
373+
s, c, scanner := testServerSelected(t, false)
374+
defer c.Close()
375+
defer s.Close()
376+
377+
io.WriteString(c, "a001 STORE 1 FLAGS somestring someanotherstring\r\n")
378+
379+
scanner.Scan()
380+
if scanner.Text() != "* 1 FETCH (FLAGS (somestring someanotherstring))" {
381+
t.Fatal("Invalid FETCH response:", scanner.Text())
382+
}
383+
384+
scanner.Scan()
385+
if !strings.HasPrefix(scanner.Text(), "a001 OK ") {
386+
t.Fatal("Invalid status response:", scanner.Text())
387+
}
388+
}
389+
372390
func TestStore_Uid(t *testing.T) {
373391
s, c, scanner := testServerSelected(t, false)
374392
defer c.Close()

0 commit comments

Comments
 (0)