diff --git a/imapserver/parse.go b/imapserver/parse.go index 74f5f09..c699f83 100644 --- a/imapserver/parse.go +++ b/imapserver/parse.go @@ -12,12 +12,13 @@ import ( ) var ( - listWildcards = "%*" - char = charRange('\x01', '\x7f') - ctl = charRange('\x01', '\x19') - atomChar = charRemove(char, "(){ "+listWildcards+ctl) - respSpecials = atomChar + "]" - astringChar = atomChar + respSpecials + listWildcards = "%*" + char = charRange('\x01', '\x7f') + ctl = charRange('\x01', '\x19') + quotedSpecials = `"\` + respSpecials = "]" + atomChar = charRemove(char, "(){ "+ctl+listWildcards+quotedSpecials+respSpecials) + astringChar = atomChar + respSpecials ) func charRange(first, last rune) string { @@ -122,7 +123,7 @@ func (p *parser) take(s string) bool { func (p *parser) xtake(s string) { if !p.take(s) { - p.xerrorf("expected %q", s) + p.xerrorf("expected %s", s) } } @@ -201,9 +202,10 @@ func (p *parser) xspace() { func (p *parser) digits() string { var n int for _, c := range p.upper[p.o:] { - if c >= '0' && c <= '9' { - n++ + if c < '0' || c > '9' { + break } + n++ } if n == 0 { return "" diff --git a/imapserver/search_test.go b/imapserver/search_test.go index 621bc6e..25b94b9 100644 --- a/imapserver/search_test.go +++ b/imapserver/search_test.go @@ -212,6 +212,9 @@ func TestSearch(t *testing.T) { tc.transactf("ok", `search uid 5`) tc.xsearch(1) + tc.transactf("ok", `search or larger 1000000 smaller 1`) + tc.xsearch() + tc.transactf("ok", `search undraft`) tc.xsearch(1, 2) diff --git a/imapserver/server_test.go b/imapserver/server_test.go index fa4a718..f9c5849 100644 --- a/imapserver/server_test.go +++ b/imapserver/server_test.go @@ -191,6 +191,7 @@ func (tc *testconn) xcodeArg(v any) { } func (tc *testconn) xuntagged(exps ...any) { + tc.t.Helper() tc.xuntaggedCheck(true, exps...) }