Files
Daniel Eggert d67ffdf153 Fix encode/parse round-trip bugs (#868)
* Separate LIST from its independent select options

`.listIndependent([.remote], …)` encoded as `LIST(REMOTE) …`.

RFC 5258: `list = "LIST" [SP list-select-opts] SP mailbox SP mbox-or-pat`.

* Keep leading zeros in fractional seconds

`12:34:56.05` parsed as `fraction: 5` and re-encoded as `12:34:56.5`,
changing the value.

RFC 3339: `time-secfrac = "." 1*DIGIT`. `FullTime.fraction` becomes
`FullTime.Fraction`, which stores the digits; `init?(_:)` validates,
literals trap, `String.init` reads.

* Model the RFC 3339 time offset

`;EXPIRE=2025-12-31T23:59:59Z` failed to parse inside a URL: the
parser stopped before `Z`. The encoder never wrote an offset.

RFC 4467: `expire = ";EXPIRE=" date-time`; RFC 3339: `full-time =
partial-time time-offset`, `time-offset = "Z" / time-numoffset`. Adds
the required `FullTime.offset`.

* Encode LIST extended data

`MailboxInfo.extensions` was parsed but never written, so
`* LIST (\Marked) "/" "Fruit" ("CHILDINFO" ("SUBSCRIBED"))` lost
`("CHILDINFO" …)` on re-encode.

RFC 5258: `mailbox-list = … mailbox [SP mbox-list-extended]`.

* Round-trip multi-value LIST option values

`.array(["a", "b"])` encoded as `(("a" "b"))`; the parser rejected both
that and `("a" "b")`: it took the `astring` branch first and could not
backtrack.

RFC 5258: `option-value = "(" option-val-comp ")"`, `option-val-comp =
astring / option-val-comp *(SP option-val-comp) / "(" option-val-comp
")"`. The parser reads a sequence of elements; the encoder writes
several values inside the `option-value` parentheses.

* Validate JMAPACCESS URLs

`.jmapAccess(URL(string: "jmap", relativeTo: base))` encoded as
`JMAPACCESS "jmap -- https://example.com/"` (`URL.description`); `http`
URLs were written though the parser rejects them.

The payload becomes `ResponsePayload.JMAPAccessURL`: `init?(_:)` resolves
against the base and requires `https`, a host, and no escaping inside
`quoted`; `URL.init` reads. The parser uses the same check.

* Make RESETKEY mechanisms require a mailbox

`.resetKey(mailbox: nil, mechanisms: [.internal])` encoded as bare
`RESETKEY`, silently dropping the mechanisms and resetting every key.

RFC 4467: `resetkey = "RESETKEY" [SP mailbox *(SP mechanism)]`. The
payload becomes `Command.ResetKeyScope`: `.allMailboxes` or
`.mailbox(_:mechanisms:)`.

* Hoist a #require the compiler flagged as redundant

* Cite RFC 7162 for SEARCH MODSEQ entry types

The docs described these as RFC 5464 GETMETADATA options, with
GETMETADATA examples. The grammar is RFC 7162 `search-modseq-ext`.

* Fix doc nits

- `ExtendedSearchScopeOptions.content` is a dictionary, not an array.
- `NamespaceDescription` init in the `NamespaceResponse` example needs
  `try` and `responseExtensions:`.
- `TaggedExtensionLabel` example: `SELECT INBOX (CONDSTORE)` parses as
  `.condStore`; use `RELEVANCY`.
- Stray `’` in a parser hint.
2026-11-04 17:41:53 +00:00
..