Skip to content

Conversation

@dejanstrbac
Copy link
Contributor

  • According to RFC 4731, a server must ignore any unrecognized RETURN options
  • handle empty NumSets
  • readSearchKeyWithAtom should return errors instead of swallowing them
  • tag in search response should be quoted, would cause iOS Mail mishandling
  • replaced deprecated strings.Title

mercata and others added 5 commits September 21, 2025 14:03
…ptions; readSearchKeyWithAtom should return errors instead of swallowing them; tag in search response should be quoted; replaced deprecated strings.Title
Copy link
Owner

@emersion emersion left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR mixes multiple unrelated things together. This makes review quite tedious.

go-imap uses linear, recipe style commits. Each commit is small and self-contained. Commits start with the name of the package they touch as a prefix.

If a PR does a single thing, I can squash the changes into a single commit and edit the commit message to conform. If the PR does multiple things but they are split into logical commits, I can review commits one-by-one, and merge them incrementally if desired.

options.ReturnSave = true
default:
return newClientBugError("unknown SEARCH RETURN option")
// RFC 4731: A server MUST ignore any unrecognized return options.
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see where this is specified in RFC 4731? This would also be surprising to clients: they ask for something and silently get a reply without it.

RFC 4466 says that return options may be followed by optional search-mod-params, so we can't just skip the name anyways.


func searchKeyFlag(key string) imap.Flag {
return imap.Flag("\\" + strings.Title(strings.ToLower(key)))
return imap.Flag("\\" + cases.Title(language.English).String(strings.ToLower(key)))
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We'll never get anything other than ASCII here. I'd prefer not to introduce a new dependency with large Unicode tables just for this.

if err := readSearchKey(criteria, dec); err != nil {
return err
}
if !dec.SP() {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why stop on non-spaces?

}
if !dec.ExpectNumSet(numKind, &data.All) {
return "", nil, dec.Err()
if dec.SP() {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Grammar from RFC 4731 says that ALL must always be followed by a seq-set:

"ALL" SP sequence-set

Is a client not conforming?


if c.enabled.Has(imap.CapIMAP4rev2) || extended {
var supportsESEARCH bool
if capSession, ok := c.session.(SessionCapabilities); ok {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like this is the only place where SessionCapabilities is used? I would've expected it to affect everything, not just SEARCH.

I do think it would be nice to be able to customize supported caps per-conn, FWIW.

@emersion
Copy link
Owner

  • readSearchKeyWithAtom should return errors instead of swallowing them
  • tag in search response should be quoted, would cause iOS Mail mishandling

These fixes LGTM, I've pushed them to v2 as 9139e6b and 864c4c3!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants