From 1e049a087d69497df42e274ea3275bdaf960bb15 Mon Sep 17 00:00:00 2001 From: Mechiel Lukkien Date: Thu, 29 Jun 2023 21:37:17 +0200 Subject: [PATCH] fix bug in imapserver with matching if a uid is in a uidset for a uid set, the syntax :* must be interpreted as :. a wrong check turned the uid set into :. that check was meant for the case where is higher than , in which case num must be replaced with maxuid. this affected "uid expunge" with a uid set, possibly causing messages marked for deletion not to be actually removed, and this affected "search" with the uid parameter, possibly not returning all messages that were searched for. found while writing tests for upcoming condstore/qresync extensions. --- imapserver/protocol.go | 2 +- imapserver/protocol_test.go | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/imapserver/protocol.go b/imapserver/protocol.go index 9541db0..26e9a90 100644 --- a/imapserver/protocol.go +++ b/imapserver/protocol.go @@ -63,7 +63,7 @@ func (ss numSet) containsUID(uid store.UID, uids []store.UID, searchResult []sto last = store.UID(r.last.number) if r.last.star { last = uids[len(uids)-1] - if last > first { + if first > last { first = last } } else if r.first.star && last < first { diff --git a/imapserver/protocol_test.go b/imapserver/protocol_test.go index 4870e5a..ff1caa8 100644 --- a/imapserver/protocol_test.go +++ b/imapserver/protocol_test.go @@ -48,6 +48,9 @@ func TestNumSetContains(t *testing.T) { check(!ss2.containsUID(2, []store.UID{4, 5}, nil)) check(!ss2.containsUID(2, []store.UID{1}, nil)) + check(ss2.containsUID(2, []store.UID{2, 6}, nil)) + check(ss2.containsUID(6, []store.UID{2, 6}, nil)) + // *:2 ss3 := numSet{false, []numRange{{*star, num(2)}}} check(ss3.containsSeq(1, []store.UID{2}, nil))