Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fetch: ensure field names are Atoms #589

Open
wants to merge 1 commit into
base: v2
Choose a base branch
from

Conversation

rakoo
Copy link
Contributor

@rakoo rakoo commented Feb 1, 2024

This PR makes sure the fields in FETCH/SEARCH are atoms.

The spec says it is allowed to have strings (ie with double quotes) here, but I'm on an IMAP server that doesn't totally respect that:

> A004 SEARCH HEADER Message-Id <[email protected]>
< * SEARCH 1
< A004 OK SEARCH done
> A004 FETCH 1 (BODY[HEADER.FIELDS (Message-ID)])
< * 1 FETCH (BODY[HEADER.FIELDS (MESSAGE-ID)] {65}
< Message-ID: <[email protected]>
< 
< )
< A004 OK FETCH done
> A004 FETCH 1 (BODY[HEADER.FIELDS ("Message-ID")])
< * 1 FETCH (BODY[HEADER.FIELDS ("MESSAGE-ID")] {2}
< 
< )
< A004 OK FETCH done

The server in question is provided by mailo.com. I know this deviates from standard, but I can only guess if we send something stricter than expected then it's ok ?

@rakoo rakoo changed the title fetch/search: ensure field names are Atoms fetch: ensure field names are Atoms Feb 1, 2024
@emersion emersion added the non-standard Interoperability with software violating the specs label Feb 1, 2024
@emersion
Copy link
Owner

emersion commented Feb 1, 2024

Unfortunately this approach breaks the case where values contain invalid atom characters, such as spaces for instance.

Oh well. I suppose we could have Encoder.AString which uses an atom if the value doesn't contain special characters?

@rakoo
Copy link
Contributor Author

rakoo commented Feb 1, 2024 via email

@emersion
Copy link
Owner

emersion commented Feb 1, 2024

Wait, there are header field names with spaces ?

Technically yes. The only character a header field can't contain is a colon. See ftext in RFC 5322 section 3.6.8.

Regardless, the string comes from the user of the library, which means that it can potentially be anything. We shouldn't produce invalid IMAP syntax even if the user provides an invalid header field name.

@rakoo
Copy link
Contributor Author

rakoo commented Feb 2, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
non-standard Interoperability with software violating the specs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants