Commit Graph
40 Commits
Author SHA1 Message Date
Daniel Eggert 1993d6177b Throw NoForwardProgress when parsing stops consuming
A parser bug that stops consuming input used to spin forever on peer
bytes: extractBytes looped with take == 0 once the cursor invariant
broke, the repetition combinators looped on an element that matched
empty, and IMAPInputProcessor looped on a decoder returning messages
without consuming. Each now throws the new public NoForwardProgress
(public init, so a decoder driver outside the library can throw it as
IMAPInputProcessor does), which no backtracking point treats as "did
not match":

- extractBytes throws when the head is empty but bytes remain; the
  scans stop when advancing their walker consumes nothing. Both also
  assertionFailure, and a debug-only check in advance compares what it
  consumed against what was visible before, so tests trap at the bug.
- forEachRepetition backs every repetition combinator and the search
  sources list; the other hand-written grammar loops check progress per
  iteration (requireProgress).
- IMAPInputProcessor allows 4 messages in a row without progress; the
  parsers emit at most 2 (commands) and 1 (responses), pinned by tests
  that run the real decoders.

Catch sites that took any error for a mismatch now catch ParserError
only, or let NoForwardProgress through: mailbox list flags, the body
and section fallbacks, and the run-away literal check. (#885 already
narrowed the tagged extension catches.)

Behavior changes: those loops now report a list cut short by the end of
the input as IncompleteMessage instead of returning what they had. Mostly
not observable through the stream parsers, which retry; a flag list
split mid-flag gets a split-at-every-byte case. The stream parser docs
tell callers who drive them directly to bound results without progress,
as the handlers do.

Reviewer focus: the catch sites, and the limit's reasoning in
IMAPInputProcessor.maximumMessagesWithoutProgress.
2026-11-25 21:19:43 +09:00
Daniel Eggert 3e2faedee1 Drop NIO from NIOIMAPCore (mostly scripted)
NIOIMAPCore and its tests no longer depend on swift-nio; NIOIMAP declares
the dependency it was getting transitively. Hand edits: Package.swift and
NIOIMAPCore.md. Everything else is the output of, on the parent
commit (zsh):

  F=($(grep -rlE '^import ((struct|enum|class|protocol) )?NIO(Core|TestUtils)?(\.[A-Za-z]+)?$' \
      Sources/NIOIMAPCore Tests/NIOIMAPCoreTests))
  perl -0pi -e 's/^import (?:(?:struct|enum|class|protocol) )?NIO(?:Core|TestUtils)?(?:\.\w+)?\n//mg;
      s/\n\n\n+/\n\n/g' $F

Public break: depending on NIOIMAPCore no longer provides swift-nio.
2026-11-25 21:19:41 +09:00
Daniel Eggert 5d9a7562d6 Rename ParseBuffer to ParseInput (scripted)
Drops the `typealias ParseBuffer = ParseInput` from "Parse from
ParseInput instead of ByteBuffer". Script output, run on the parent
commit (zsh), plus one hand edit:

  git rm Sources/NIOIMAPCore/Parser/ParseBuffer.swift
  F=($(grep -rl '\bParseBuffer\b' Sources/NIOIMAPCore/Parser))
  perl -pi -e 's/\bParseBuffer\b/ParseInput/g' $F
  swift format -i $F

swift-format re-joins signatures that now fit in 120 columns.

Hand edit: the same rename in Tests/NIOIMAPCoreTests/TestUtilities.swift,
outside the script's grep.
2026-11-25 21:19:41 +09:00
Daniel Eggert d309926c18 Deliver received literals zero-copy via IMAPInputProcessor
The handlers stage reads in an IMAPInputBuffer (IMAPInputProcessor)
instead of NIOSingleStepByteToMessageProcessor's coalesced ByteBuffer,
so a FETCH/APPEND literal piece of at least 1 KiB within one read of
at least 1 KiB is delivered as a reference to the received bytes.
Shorter pieces are copied; bytes from smaller reads are copied twice,
into a tail on arrival and out of it on delivery. The decoders keep
their ByteBuffer entry point for ByteToMessageHandler and the decoder
verifier; that path copies.

A decoder error or PayloadTooLargeError is final: the buffer is dropped
and later reads rethrow it without decoding (ByteToMessageHandler also
stops decoding, but fires dataReceivedInErrorState). Keeping the
unparsed bytes would make every later read append, fail on the same
bytes and copy all of them into IMAPDecoderError.buffer: unbounded
memory and quadratic copying, past the maximumBufferSize check. Errors
thrown by the message receiver (e.g. UnexpectedResponse) pass through
and are not final.

Reads under 1 KiB are copied into IMAPInputBuffer's tails, so 1-byte
reads cost a region per KiB and pin no receive buffers. A larger read
still pins its whole receive buffer, which maximumBufferSize does not
count.

Review focus: IMAPInputProcessor.

Behavior changes:
- A stream whose input failed to parse stays failed.
- IMAPDecoderError.buffer holds the bytes waiting to be parsed when the
  error was thrown.
- Leftover literal bytes followed by a read that starts a new region
  reach the handler's consumer as two .streamingBytes events, not
  one. Every read of at least 1 KiB starts a region; a smaller one
  does when the last region is a retained read, or a tail it does not
  fit or that is not uniquely referenced.
  ParseInput.extractBuffer(upTo:) takes bytes from the current region
  only, where the old code took min(remaining, readable) across the
  whole buffer. Legal, but observable. A caller passing a multi-region
  buffer to the stream parsers directly sees this from the previous
  commit on.
2026-11-25 21:19:40 +09:00
Daniel Eggert 46f2996366 Parse from ParseInput instead of ByteBuffer
The grammar now runs on the ~Escapable ParseInput cursor; ParserLibrary
and its ParseBuffer are deleted. The stream parsers are generic over
ConsumableParserInputBuffer and gather once per call: CommandParser
frames synchronizing literals and parses through the same cursor,
narrowing its limit instead of slicing. The NIO handlers still feed
ByteBuffers, through its ParserInputBuffer conformance.

Review focus: CommandParser.parseCommandStream and
ResponseParser.parseResponseStream (what is consumed on each exit path).

Behavior changes:
- Stray spaces before a line ending: up to
  ParseInput.maximumStraySpaces (1024) are accepted; more throw
  ParserError. On main, PL.parseNewline recursed through composite once
  per space, so ~100 threw TooMuchRecursion from the shared 100-frame
  tracker. Both a looser limit and a different error type.
- Trailing spaces with no line ending yet report IncompleteMessage while
  under the cap, where they used to throw ParserError. Fixes the client
  side (ResponseParser), which has no framing layer, for a read split as
  "* 1 EXISTS " | "\r\n".
- From an IMAPInputBuffer, payload pieces of at least 1 KiB taken from
  a retained read (>= 1 KiB, fixed address) refer to it; a large Data
  is retained as the buffer's one copy. Smaller pieces and tail bytes
  are copied. From a bare ByteBuffer, payloads are copied.

Grammar edits beyond the cursor: the QUOTA resource loop binds
parseOptional's result to an explicit `Void?`, and parseLookupKeyword
loses a comment about the tracker it no longer takes. ParserError.hint
gains a note to keep hot-path hints literal: ParserLibrary's
interpolated ones, deleted here, allocated on every mismatch.

Public API break: parseCommandStream(buffer:) and
parseResponseStream(buffer:) are generic. ByteBuffer conforms in
NIOIMAP, so a caller importing only NIOIMAPCore must import NIOIMAP to
pass one.

Temporary: `typealias ParseBuffer = ParseInput` keeps the grammar's
spelling until "Rename ParseBuffer to ParseInput (scripted)". Removes
LegacySubParser, the ParseBuffer cursor-method shim and the framing
bridge from "Move SynchronizingLiteralParser onto ParserInputBuffer".
2026-11-25 21:19:40 +09:00
Daniel Eggert 27fd842a18 Move SynchronizingLiteralParser onto ParserInputBuffer
The framing pass reads through a ParseInput cursor instead of a
ByteBuffer: one region scan per line ending, then a few peeks backwards
from it to classify the line. An internal overload takes a cursor the
caller has already gathered, so the command parser can later frame and
parse through one gather.

Review focus: SynchronizingLiteralParser over a cursor (findLineEnd,
lineFragmentType; every index is a distance from the read position).

Public API break:
SynchronizingLiteralParser.parseContinuationsNecessary(_:) is generic
over ParserInputBuffer. ByteBuffer conforms in NIOIMAP, so a caller
importing only NIOIMAPCore must import NIOIMAP to pass one.

Temporary: CommandParser builds a cursor over its ByteBuffer to call the
framing pass, until it takes a ParserInputBuffer itself.
2026-11-25 21:19:40 +09:00
Daniel Eggert a5375d0d56 Make payload cases IMAPBuffer
The four raw-payload cases become IMAPBuffer so a large literal can be
handed in and out without a copy: FetchResponse.streamingBytes,
AppendCommand.messageBytes, AppendCommand.CatenateData.bytes,
CommandStreamPart.continuationResponse.

Review focus: writeBytes(IMAPBuffer) keeps payloads by reference
(ZeroCopyWriteTests); the parser's extractBuffer(upTo:) still copies.

Updates IMAPTool and the IMAPCommands append/continuation wrappers.

Public API breaks:
- The four cases above: ByteBuffer -> IMAPBuffer.

Removes the writeBuffer(inout ByteBuffer) shim from "Encode into an
EncoderOutputBuffer sink".
2026-11-25 21:19:40 +09:00
Daniel Eggert 4bba8e9e4f Use [UInt8] for small model fields
Small fields (mailbox names, atoms, quoted strings, envelope fields,
base64, URLs, the authentication challenge, catenateURL, ...) become
[UInt8]. The four raw-payload cases stay ByteBuffer until "Make payload
cases IMAPBuffer".

The grammar's string productions return [UInt8]. The parser still runs
on ParseBuffer, so its cursor methods copy out of the ByteBuffer for now.

Review focus: the model files' encoders and ModifiedUTF7 on arrays.

Updates IMAPTool and the IMAPCommands catenate-URL wrapper.

Public API breaks:
- ~38 public declarations ByteBuffer -> [UInt8].
- ModifiedUTF7.EncodingRoundtripError.buffer -> .bytes.
- Response.authenticationChallenge and ContinuationRequest.data are
  [UInt8]; an empty challenge is [].

Internal: writeBufferAsBase64 -> writeBytesAsBase64; the ByteBuffer
writeIMAPString overload is gone.
2026-11-25 21:19:40 +09:00
Daniel Eggert 46943f2ef7 Rewrite grammar calls as cursor methods (scripted)
`PL.f(…, buffer: &b, tracker: t)` becomes `b.f(…)`, the spelling
ParseInput's primitives and combinators use, so that swapping the cursor
later touches only primitives. Bare grammar functions passed as values
become `{ try f(buffer: &$0, tracker: $1) }`.

Behavior unchanged except recursion accounting: leaf primitives
(matchFixed, parseSpaces, readByte, ...) no longer spend a frame of the
caller's StackTracker, so input at the depth limit can nest one to three
levels deeper. This is permanent, not a shim artifact: ParseInput's
leaves take no tracker. At the end of the stack SEARCH nesting depth 90
parses and 91 throws TooMuchRecursion (searchNestingDepthBoundary).
While the shim exists, matchNewline gets a fresh 100-frame budget.

ParseBuffer+CursorMethods.swift (hand-written, temporary) forwards the
new spellings to ParserLibrary; the rest is the output of the script
below. To reproduce, on the parent commit:

  F=(Sources/NIOIMAPCore/Parser/Grammar/*.swift
     Sources/NIOIMAPCore/Parser/{Command,Response}Parser.swift)
  python3 rewrite_grammar.py $F && swift format -i $F

rewrite_grammar.py:

    #!/usr/bin/env python3
    # Rewrites ParserLibrary calls (`PL.f(…, buffer: &b, tracker: t)`) into cursor methods (`b.f(…)`),
    # the shape ParseInput's primitives and combinators have.
    #
    # Usage: python3 rewrite_grammar.py FILE...    (in place), then `swift format -i FILE...`
    import re
    import sys

    LIT = r'"(?:[^"\\]|\\.)*"'  # a string literal
    B = r'buffer:\s*&(\w+)'     # the cursor argument; its name becomes the receiver
    T = r'tracker:\s*([\w.]+)'  # the tracker argument

    RULES = [
        # Primitives that take no tracker. Their arguments are kept; `buffer:` and `tracker:` go.
        (rf'PL\.parseFixedString\((\s*)({LIT}|\w+)((?:,\s*\w+:\s*[\w.]+)*),\s*{B},\s*{T}\s*\)', r'\4.matchFixed(\1\2\3)'),
        (rf'PL\.parseFixedByte\(\s*([^,()]+),\s*{B},\s*{T}\s*\)', r'\2.matchByte(\1)'),
        (rf'PL\.parseSpaces\(\s*{B},\s*{T}\s*\)', r'\1.parseSpaces()'),
        (rf'PL\.parseNewline\(\s*{B},\s*{T}\s*\)', r'\1.matchNewline()'),
        (rf'PL\.parseByte\(\s*{B},\s*{T}\s*\)', r'\1.readByte()'),
        (rf'PL\.parseBytes\((\s*){B},\s*{T},\s*length:', r'\2.extractBytes(\1length:'),
        (rf'PL\.parseBytes\((\s*){B},\s*{T},\s*upTo:', r'\2.extractBuffer(\1upTo:'),
        (rf'PL\.(parse(?:Zero|One)OrMoreCharacters)\(\s*{B},\s*{T}\s*\)', r'\2.\1'),
        (rf'PL\.(parse(?:Zero|One)OrMoreCharacters)\((\s*){B},\s*{T},\s*', r'\3.\1(\2'),
        # `parser: PL.parseSpaces` as a value: spaces take no tracker, so it needs a closure.
        (r'parser:\s*PL\.parseSpaces\b', r'parser: { input, _ in try input.parseSpaces() }'),
        # Combinators keep their tracker; only `buffer:` moves to the receiver.
        (rf'(?:PL|ParserLibrary)\.(composite|parseOptional|parseZeroOrMore|parseOneOrMore|parseUnsignedInteger|parseUnsignedInt64)\((\s*){B},\s*',
         r'\3.\1(\2'),
        (r'(?:ParserLibrary|PL)\.parseBufferAsUTF8\(', r'decodeUTF8('),
        # The cursor takes enums where ParserLibrary took Bools.
        (r'\bcaseSensitive:\s*true\b', 'caseSensitivity: .caseSensitive'),
        (r'\bcaseSensitive:\s*false\b', 'caseSensitivity: .caseInsensitive'),
        (r'\ballowLeadingSpaces:\s*true\b', 'leadingSpaces: .allowed'),
        (r'\ballowLeadingSpaces:\s*false\b', 'leadingSpaces: .rejected'),
        (r'\ballowLeadingZeros:\s*true\b', 'leadingZeros: .allowed'),
        (r'\ballowLeadingZeros:\s*false\b', 'leadingZeros: .rejected'),
    ]

    # Two call sites the hand-written code spells with a trailing closure rather than `parser:`.
    TRAILING = ['parseByteRange_length', 'parseQuotaLimit']

    # Grammar functions passed as values become closures, `{ try parseX(buffer: &$0, tracker: $1) }`: a
    # local function over a non-escapable cursor cannot be a function value before Swift 6.4. `self.`
    # method references stay as they are, and so does `parse2Digit`, which the hand-written code never
    # wrapped.
    KEEP = {'parse2Digit'}

    def wrap(name):
        return name if name in KEEP else f'{{ try {name}(buffer: &$0, tracker: $1) }}'

    def closing(src, k):
        """Index just past the bracket matching the one before `k`."""
        depth = 1
        while depth:
            c = src[k]
            if c in '([{':
                depth += 1
            elif c in ')]}':
                depth -= 1
            k += 1
        return k

    def depth0(src, end):
        """Whether `src[end]` is outside every bracket opened in `src[:end]`."""
        depth = 0
        for c in src[:end]:
            depth += c in '([{'
            depth -= c in ')]}'
        return depth == 0

    def rewrite_one_of(src):
        # PL.parseOneOf(a, b, buffer: &x, tracker: t) -> x.parseOneOf(a, b, tracker: t), wrapping bare
        # `parseX` alternatives as above.
        out, i = [], 0
        while (j := src.find('PL.parseOneOf(', i)) >= 0:
            k = j + len('PL.parseOneOf(')
            m = closing(src, k)
            args = src[k:m - 1]
            arg = next(a for a in re.finditer(r'(\s*)buffer:\s*&(\w+),', args) if depth0(args, a.start()))
            args = args[:arg.start()] + args[arg.end():]
            args = re.sub(r'(?<=[(\[,])(\s*)(parse\w+)(?=\s*[,)\]])', lambda a: a.group(1) + wrap(a.group(2)), '(' + args)[1:]
            out += [src[i:j], f'{arg.group(2)}.parseOneOf(', args, ')']
            i = m
        return ''.join(out) + src[i:]

    for path in sys.argv[1:]:
        src = open(path).read()
        for pattern, replacement in RULES:
            src = re.sub(pattern, replacement, src)
        src = rewrite_one_of(src)
        for name in TRAILING:
            src = re.sub(rf',\s*parser:\s*{name}\s*\)', f') {{ try {name}(buffer: &$0, tracker: $1) }}', src)
        src = re.sub(r'(parser:\s*)(parse\w+)\b(?!\()', lambda m: m.group(1) + wrap(m.group(2)), src)
        open(path, 'w').write(src)
2026-11-25 21:19:40 +09:00
Daniel Eggert b2c94a8bce Only skip an orphaned LF after a response-ending CR (#882) 2026-11-10 17:49:13 +01:00
Daniel Eggert abfc170ff1 Only parse continuation responses while an AUTHENTICATE is in progress (#827) 2026-06-01 14:13:22 -04:00
Daniel Eggert 34883bcba6 Update style in documentation (#822) 2026-04-28 18:06:43 +02:00
Daniel Eggert 871d0122c9 Better docc comments (#815) 2026-04-16 09:20:29 -07:00
Franz Busch 2cd1c5582a [CI] Adopt GitHub Actions (#775)
* [CI] Adopt GitHub Actions

# Motivation

We want to adopt GitHub actions in all of our Swift repositories to replace our current Jenkins CI.

# Modification

This PR adopts the reusable workflows from NIO and the swiftlang organization to ensure soundness and test coverage. Additionally, this PR enables a sematic label check and adds a `release.yml` to make releasing this package easy.

# Result

Modern CI and release flow.
2024-10-30 13:24:35 +00:00
Matt Diephouse 7d0f2cf799 Mark final set of types as Sendable (#771) 2024-09-18 15:06:30 +02:00
David Evans 480785353a Add literal size limit (#671) 2022-01-26 12:07:49 +01:00
David Evans 69f15a10ba Convert line length limit to 8192 (#666)
Resolves #663

Convert the default limits from 1000 to 8192 octets, as per RFC 7162.
2021-12-23 13:36:54 +00:00
David Evans c4d572029e Make grammar parser non-static (#661)
The static grammar parser has served us well and has been very easy to use. Sadly, however, the time for static to die has arrived, as we now need the parser to be configurable with certain limits (e.g. maximum supported message body size).

This is kind of simple, just remove static from everywhere, and then use instances of the parser instead of calling the static methods.

It is massive though, sorry.
2021-12-17 10:54:34 +00:00
David Evans fe03b16eb1 Fix Hashable implementations across all types (#648)
Resolves #634

The majority of types that were Equatable are now Hashable.

Anywhere that we had a custom == and the type was also Hashable we also now have custom hash functions.
2021-12-10 13:58:41 +00:00
David Evans a66eeb228b Use SPI to remove underscored members (#567)
Resolves #556

We've talked quite a bit offline, and decided that for now @_spi is the way to go, as it avoids build system issues. The goal is to remove the number of underscored public types and fields.
2021-06-02 19:21:47 +01:00
David Evans 8565ac900e Rename Command types to better represent what they are (#557)
Resolves #522

Some command names were misleading, they should be better now. Also removed a redundant initialiser.

PartialCommandStream -> SynchronizedCommand

CommandStream -> CommandStreamPart
2021-05-21 16:39:22 +01:00
David Evans 22b38c56ed Parser cleanup (implement shortcut methods, use new parse oneOf) (#509) 2021-03-31 11:21:34 +01:00
8b9c01a6ba Servers now can send authentication challenges (#505)
* Servers now can send authentication challenges

* Soundness

* Fix tests

* Change to use Response

* Docs

* Soundness

* work around SR-14394

* Update Sources/NIOIMAPCore/Grammar/Response/Response.swift

Co-authored-by: Daniel Eggert <daniel.eggert@hoerbuch.dk>

* Fix compile on 5.2

Co-authored-by: Johannes Weiss <johannesweiss@apple.com>
Co-authored-by: Daniel Eggert <daniel.eggert@hoerbuch.dk>
2021-03-23 16:33:36 +00:00
David Evans f1e7faa75f Propagate command tag on parsing error (#500)
* Propagate command tag on parsing error

* Soundness

* Docs

* Fix tests
2021-03-23 10:04:16 +00:00
David Evans 80a2910e63 Implement table parser with commands example (#437)
* Performance structure

* More tests

* Add more tests

* Remove dups

* More performance test cases

* Parse it all

* Fix sanity

* Use NIO perf tooling

* Change perf target name

* New table parser

* Fix quota parsers

* Fix ID parsers

* Human readable

* Cleanup

* Soundness

* Fix tests

* Minor refactor to use suffixes

* Tests

* Make parsing table non-global

* Rebase

* Soundness

* Tests

* More tests

* Soundness

* Fix compile

* Condense

* Maybe fix
2021-03-22 09:25:17 +00:00
David Evans 238caca684 Skip parsing if the ByteBuffer is empty (#478)
* Don't attempt parsing if 0 bytes

* Soundness

* undo

* Update CommandParser+Tests.swift
2021-03-16 11:53:52 +00:00
Johannes Weiss be9c737a29 restore separation of parser & parser library (#468) 2021-03-11 16:56:08 +00:00
David Evans 135f473bf6 Documentation PR part 5 (#383)
* Document UseAttribute

* Document URLRumpMechanism

* Document URLFetchData

* Document UAuthMechanism

* Document StoreModifier

* Document SortData

* Document SequenceMatchData

* Document QResyncParameter

* Document SelectParameter

* Document SectionSpecifier

* Document SectionSpecifier.Part

* Document SectionSpecifier.Kind

* Document ResponseEncodingOptions

* Document ResponseEncodeBuffer

* Document EncodeBuffer

* Document EncodeBuffer.Chunk

* Document EncodeBuffer more.

* Document CommandEncodeBuffer

* Document ParserError

* Document ResponseParser

* Document CommandParser

* Document SynchronisingLiteralParser

* Remove public where it isn't needed

* Document write CommandStream

* Document write TaggedCommand

* Remove public from write functions

* Document FetchAttribute

* Document top-level Capability

* Documents Capability subtypes

* Document FullDateTime

* Document FullDate

* Document FullTime

* Document ContinuationRequest

* Document ListSelectOptions

* Document ResponseOrContinuationRequest

* Document Response

* Document FetchResponse

* Document StreamingKind

* Document ResponseText

* Document ResponseTextCode

* Document TaggedResponse

* Document TaggedResponseState

* Remove docs

* PR review

* Fix sanity

* Document FullDate
2020-12-10 12:37:05 +00:00
David EvansandGeorge Barnett 78b55555bf Add some documentation (#341)
* Fix documentation

* Remove link to NIO http 2

* Document TooDeep error

* Remove ParsingError

* Make GrammarParser non-public

* Better UTF7 errors

* Document Access

* Document CommandStream types

* Partially document `Command`

* Document date

* Document Access

* Update Sources/NIOIMAPCore/Grammar/Date/Date.swift

Co-authored-by: George Barnett <gbarnett@apple.com>

* Update Sources/NIOIMAPCore/Grammar/Access.swift

Co-authored-by: George Barnett <gbarnett@apple.com>

* Update Sources/NIOIMAPCore/Grammar/Command/CommandStream.swift

Co-authored-by: George Barnett <gbarnett@apple.com>

* Fix typo

Co-authored-by: George Barnett <gbarnett@apple.com>
2020-10-26 09:54:46 +00:00
David Evans 1f9658005f Refactor parsing (#321)
* Refactor parse space

* Refactor parse fixed string

* Refactor parseOneOf

* Refactor parseOptional

* Refactor parseComposite

* Refactor parseNewline

* Fix sanity

* Rebase fixes
2020-09-28 13:22:10 +01:00
Cory Benfield f3d154b06c Implement RFC 4469 CATENATE (#310)
Motivation:

CATENATE functionality is convenient for low-power client usage, as it
allows clients to stitch together new messages out of the parts of older
ones without needing to reupload (or indeed redownload) that content.

Modifications:

- Extend CommandStream to support CATENATE.
- Extend serializer and parser to work with new definitions.

Result:

CATENATE is parseable.
2020-09-15 11:08:14 +01:00
David Evans 495d5f8c4b Refactor tests part 2 (#279)
* Update testParse2Digit

* Update testParseToken

* Update testParseUnsubscribe

* Update testParseUID

* Update testParseUIDSet

* Update testParseUserId

* Update testUIDRange

* Update testParseUid

* Update testParseText

* Fix sanity

* Remove un-needed function

* Update parseTaggedResponse

* Update parseTag

* Update parseSequenceSet

* Update parseRename

* Update parseSubscribe

* Update parseStoreAttribueFlags

* Update parseStore

* Update parseStatus

* Update testParseSequenceSet

* Update parse NZNumber

* Update parseNumber

* Update parseNString

* Test utilities for void returning parsers

* Update testParseNil

* Update testParseNewline

* Update testParseNamespace

* Update testParseAddress

* Better error messages

* Update testParseSequenceRange

* Fix testParseStatus

* Update testParseSequenceNumber

* Update testParseSelect

* Update testParseSectionSpecifierKind

* Update testParseSectionSpecifier

* Update testParseSectionPart

* Update testParseSectionBinary

* Update testParseSection

* Update testParseSearchReturnOptionExtension

* Batch replace function calls

* Use new method almost everywhere

* Remove extra spacing

* Fix sanity

* Remove redundant function

* Remove redundant code

* Refactor parsing search keys
2020-07-31 01:54:17 -07:00
Johannes WeissandDavid Evans 525d58d1fa non-happy path tests: over/underflows (#220)
* Support encoding append commands

* Yay it works

* Cleanup 1

* Cleanup 2

* Fix sanity

* Fix command decoder test

* Fix parsing partial commands sync literals

* Fix parser stress tests

* Fix tests

* Remove unused code

* Code refactor and cleanup

* Fix sanity

Co-authored-by: David Evans <d.evans@apple.com>
2020-06-26 14:47:40 +01:00
David Evans a06b3898aa Hide incomplete message errors (#135)
* Hide incomplete message errors

* Fix sanity

* Throw error

* Fix rebase

* Refactor

* Log not throw

* Improve roundtrip handler

* Fix sanity

* Update comments

* Remove error case

* Logging

* PR review

* Simplify loop

* Use NIOSinglestep...

* Fix sanity

* Even more efficiency

* Fix sanity
2020-05-28 13:49:11 +01:00
David EvansandJohannes Weiss 042d11fe17 Add B2MD tests for most commands/responses (#125)
* Move tests to dedicated file

* Add NOOP tests

* Add capability tests

* Add logout tests

* Add starttls tests

* Add select tests

* Add examine tests

* Fix sanity

* Add create tests

* Add delete tests

* Fix sanity

* Add subscribe tests

* Add unsubscribe tests

* Add missing test file header

* Add check tests

* Fix sanity

* Rebase

* Add list tests

* Add LSUB tests

* Add status tests

* Add append tests

* Setup response tests

* Allow response parse mode override

* Temp remove append

* Conditional state tests

* Bye tests

* Capability tests

* Flags tests

* Exists tests

* Recent tests

* Expunge tests

* Tagged response tests

* List, LSUB, and status tests

* Comment everything

* Make tests use synchronizing literals

* Replace CRLF

* Test fetch responses

* Fix sanity

* Assert

* Refactor error catching

* Test that breaks synchronising literals

* fix some stuff

* Fix sanity

* Fix all the things

* Fix sanity

Co-authored-by: Johannes Weiss <johannesweiss@apple.com>
2020-05-20 17:40:56 +01:00
Daniel Eggert 17c740a21b Change TaggedCommand property name and property order. (#154) 2020-05-20 10:50:18 +01:00
David Evans 28225ece7d Remove NIOIMAP namespace 2020-05-09 14:46:42 +01:00
tomer doron 53efab1d95 standardize format (#80)
motivation: use standard format across all of our projects

changes:
* add .swiftformat settings based on what we use in other projects
* validate format in the sanity script
* format
2020-04-24 12:05:17 +01:00
David Evans 0f5de678e5 Rename top-level command types and flatten UID commands into Command (#90)
* Flatten UID commands

* Rename command types
2020-04-23 16:22:56 +01:00
David Evans 19ecdb9576 Seperate module (#61) 2020-04-20 12:41:39 +01:00