* [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.
When the response text of a continuation response began with base64 characters, the response would be interpreted as base64. Any remaining characters would cause a parser error.
Rework the parser to only interpret the text as base64 if all of the text is base64 characters.
Each “part” in a `BodyStructure` has an RFC 2045 “media type” — which is a combination of “top level type” + “sub-stype”.
But the types that were previously used, were inconsistently used / named. This PR cleans up the use of these and makes them consistent.
Additionally it adds a
```swift
extension BodyStructure {
public var mediaType: Media.MediaType
}
```
such that it’s easy to get to a part’s media type, regardless of its kind.
Modification sequence numbers need to be in the range 0-Int64.max (63 bit unsiged values). When parsing, use the failing initializer, instead of the one with a `precondition()`.
The `FramingParser` might split a `CRLF` lineline into `CF` only (`LF` in the “next frame”). The `CommandParser` thus needs to be able to parse
```text
A26 UID FETCH 1:10002 (UID FLAGS MODSEQ)\r
```
as a valid and complete command.
Found by Mail during the live-on program.
The issue was caused by a "completely nil" address, which we take to mean the end of an envelope group (as per rfc 2822). A completely nil address is valid on its own, without being part of a group, however we assumed that it would always denote the end. If a group hadn't previously been started then we'd crash.
Fix by checking if we have a group on top of the stack when attempting to compile individual addresses into groups.
Also added a test case to prevent regression.
The existing code was not able to differentiate between
A1 SEARCH ANSWERED
A1 SEARCH RETURN () ANSWERED
commands. The former is an RFC 3501 style search, the latter an RFC 4731 style search.
RFC 3501 does not allow for any RETURN options.
With this PR, those get mapped to
public enum Command: Hashable {
...
case search(key: SearchKey, charset: String? = nil, returnOptions: [SearchReturnOption] = [])
such that returnOptions are empty for RFC 3501 style searches, wheras RFC 4731 style searches will always contain at least one element.
Note that RETURN () is a shorthand for RETURN (ALL), and as such gets mapped to [.all].
This is called out in the comments for Command.search.
Also
The SearchCorrelator’s tag is now a String to align with TaggedCommand’s tag.
SearchReturnData now uses UnknownMessageIdentifier instead of Int for min and max.
Resolves#684
iCloud is sending nil for message encoding types, which isn't allowed according to the spec. That said, we have to support it regardless, so we now support nil for the message encoding.
Also added some body parsing tests as there apparently weren't any "combined" ones like this. Additionally as there are multiple ways of saying "multipart/mixed" and other "multipart/*" subtypes, we now check and merge them.
Resolves#669
Maintaining many versions of the same string can be expensive for strings over a given size (10 bytes), where they become heap-allocated. For example, in IMAP there may be many thousands of messages with the same flags (e.g. deleted, seen, replied).
Here we introduce a user-controllable cache that allows the user to provide a single instances of some strings if they require. Whenever we parse an atom (i.e. a string), that string is passed to the cache (which defaults to just returning the string), which may then return a cached version.
Resolves#402
To prevent a massive amount of fetch attributes from being sent maliciously, the parser now supports a configurable limit on how many fetch attributes are allowed. If this limit is exceeded then an error is thrown.
Added some tests to show that this works for both "simple" attributes, and ones that involve streaming.
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.
Resolves#656
The UID STORE command takes an OrderedDictionary argument for the modifiers. This is both inconvenient and technically incorrect as it doesn't store the right kind of data.
Resolves#604
Rename modificationSequence to just modified as it might not contain SequenceNumbers. Also change the associated type from SequenceSet (aka MessageIdentifierSet<SequenceNumber>) to UnknownIdentifier, which can then be treated as either UIDs or SequenceNumbers depending on what the user is expecting.
(Note this is required as it is impossible to distinguish between SequenceNumbers and UIDs when parsing).
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.