Repository navigation
feat(imap): support the NAMESPACE extension (RFC 2342) - #295
Merged
Merged
Conversation
Adds `ImapClient.namespace()`, which sends NAMESPACE and returns a `NamespaceResponse` with the personal, other users' and shared namespaces — each a `Namespace` carrying the prefix (as sent, and decoded from modified UTF-7 like `Mailbox.path`), the hierarchy delimiter (`null` for NIL) and any response extensions — plus `ImapServerInfo.supportsNamespace` / `capabilityNamespace`. The parser follows the RFC 2342 section 6 grammar strictly: prefixes and extension values are IMAP strings (quoted or literal; a literal arrives as its own raw response line and stays one token), the only bare atom is NIL, and a response that does not match the grammar is not consumed, so `namespace()` returns `null` rather than a guess. NO/BAD surfaces as an `ImapException` like every other command. Tests: the RFC's examples 5.1–5.9 verbatim, a NIL delimiter, quoted specials, a modified-UTF-7 prefix, a literal prefix, malformed responses; mock-server round trips for the command, a literal, an OK without a NAMESPACE line, and a BAD. (cherry picked from commit 9a6a7cd)
Member
|
Thanks a bunch, looks great! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds the IMAP
NAMESPACEextension (RFC 2342):ImapClient.namespace()sendsNAMESPACEand returns aNamespaceResponsewith the personal, other users' and shared namespaces. EachNamespacecarries the prefix as sent (encodedPrefix) and decoded from modified UTF-7 (prefix, the same codecMailbox.pathuses), the hierarchy delimiter (nullforNIL) and any response extensions.ImapServerInfo.supportsNamespace/ImapServerInfo.capabilityNamespace.The parser follows the RFC 2342 §6 grammar strictly: prefixes and extension values are IMAP strings (quoted or literal — a literal arrives as its own raw response line and stays one token), the only bare atom is
NIL, and a response that does not match the grammar is not consumed, sonamespace()returnsnullinstead of a guess.NO/BADsurfaces as anImapExceptionlike every other command.Motivation: a FidoNet-over-IMAP gateway I write a client for now advertises its conference tree as the shared namespace (
* NAMESPACE (("" "/")) NIL (("Echoes/" "/"))), and a client should discover that prefix instead of hardcoding it — the reason the RFC exists.Tests
test/src/imap/namespace_parser_test.dart: the RFC's examples 5.1–5.9 verbatim, aNILdelimiter, quoted specials, a modified-UTF-7 prefix, a literal prefix, malformed responses, an unrelated untagged line,toString.test/imap/imap_client_test.dart: mock-server round trips for the command, a literal prefix, anOKwithout aNAMESPACEline (→null), and aBAD(→ImapException).dart analyzeadds no new issues;dart formatclean;dart testpasses (463 tests).