hn.today

Quality IMAP, Part 1: Your Mailbox Is a Database

aerogramme.deuxfleurs.fr3 points0 comments
Screenshot of Quality IMAP, Part 1: Your Mailbox Is a Database

IMAP mailboxes are better understood as databases than as folders of message files: clients issue complex queries and request only selected headers, MIME parts, or byte ranges, making correct parsing and retrieval essential. Aerogramme’s SEARCH and FETCH commands operate through an interpreter over parsed email trees. Its eml-codec library builds those trees while preserving access to original byte slices, and the server separates mailbox state and parsed metadata in Garage K2V from message bodies in Garage S3. This lets SEARCH use stored metadata without reading every message body; a full-text search engine is identified as a likely future optimization.

Testing exposed how easily IMAP’s ambiguous specifications lead to incorrect behavior. Dovecot’s ImapTest suite found SEARCH edge-case bugs and showed that Aerogramme’s original handling of FETCH BODY, which selects message parts by traversing their structure, was wrong in many cases. Additional comparisons with Dovecot helped guide fixes, now incorporated into Aerogramme releases. One unresolved dispute concerns whether SEARCH FROM should match equivalent address spellings: Aerogramme searches the displayed header text, while ImapTest expects quoted and unquoted forms of the same address to match. The specification’s reference to searching a structured address does not explain how to compare it with a string. To strengthen the parser beneath these queries, the team also uses structure-aware fuzzing and property-based tests, including checking that printing an AST and parsing it again preserves an equivalent structure.

Read on aerogramme.deuxfleurs.fr0 comments on Hacker News

Summary generated by AI from the linked article. hn.today is not affiliated with Hacker News or Y Combinator.

More in Programming

The daily digest

Today's best Hacker News stories, summarized and screenshotted, one email a day.