Files
Daniel Eggert 4606da62d2 Validate response text, command tags and namespace delimiters (#866)
* Reject invalid response text when writing

`.no(.init(text: "No mailbox x\r\n* BYE pwned"))` was written verbatim,
injecting an untagged response; likewise tagged, BYE, PREAUTH and
continuation responses.

RFC 9051: `text = 1*(TEXT-CHAR / UTF8-2 / UTF8-3 / UTF8-4)`. `writeText`
now asserts no NUL, CR or LF. Empty stays valid. The parser now accepts
UTF-8 text.

* Add Command.Tag for command and response tags

`TaggedCommand(tag: "A1 NOOP\r\nA2 DELETE INBOX\r\nA3", command: .noop)`
was written verbatim, injecting a command; likewise `APPEND` start.
`TaggedResponse(tag: "* BYE x\r\nA1", …)` injected a response.

RFC 3501: `tag = 1*<any ASTRING-CHAR except "+">`. New `Command.Tag`
replaces the `String` in `TaggedCommand`, `TaggedResponse`, `Response`,
`CommandStreamPart`, `AppendCommand`, `BadCommand` and NIOIMAP's state
machine errors; `init?(_:)` validates, literals trap. The parser already
enforces the production. IMAPCommands converts its numeric tags.

* Validate and escape namespace delimiters

`NamespaceDescription(string: "x", char: "\r\n", …)` wrote a raw CRLF
inside `"…"`, injecting a response. `"\""` encoded as `"""`, and `"\\"`
as `"\"` (unterminated); non-ASCII was accepted.

RFC 2342: `DQUOTE QUOTED-CHAR DQUOTE / nil`. `init(string:delimiter:
responseExtensions:)` (was `char:`) throws `InvalidDelimiterError` for
non-ASCII, CR, LF, NUL; the delimiter is stored as a byte, read-only.
Quoted-specials are escaped on write and parsed when escaped.

* Gate a capturing exit test on Swift 6.3
2026-11-04 17:41:52 +00:00
..
2026-08-29 09:23:34 +02:00
2026-08-29 09:23:34 +02:00
2026-08-29 09:23:34 +02:00

Examples

This directory contains example and tool projects built on top of swift-nio-imap. Each subdirectory is its own standalone Swift package that depends on the library in the repository root via a local path dependency (.package(path: "../..")).

Keeping them out of the root package means the library's own dependency graph stays smaller — consumers don't resolve example-only dependencies such as ArgumentParser. (Dependencies that the library products themselves use — for example swift-log, which IMAPCommands depends on — remain part of the root package's graph.)

Example What it is
IMAPTool Command-line IMAP debugging tool (imap-tool) built on the IMAPToolLib library product.
CLI A smaller command-line interface plus its supporting CLILib (with tests).
Proxy An IMAP proxy that logs the traffic flowing through it.
Fuzzer Fuzzing harness for the IMAP parser (NIOIMAPFuzzer).
PerformanceTester Micro-benchmarks for parsing/encoding (NIOIMAPPerformanceTester).

Building and running

Each example builds independently. From the repository root:

swift build --package-path Examples/IMAPTool
swift run   --package-path Examples/IMAPTool imap-tool --help

Because they are separate packages, swift build / swift test at the repository root builds only the library targets — not these examples. CI builds them via a dedicated Build examples job.