mirror of
https://github.com/apple/swift-nio-imap
synced 2026-11-28 05:14:27 +00:00
Always encode non-synchronizing literal with + (#676)
RFC 7888, section 5 says: > Note that the form of the non-synchronizing literal does not change: it still uses the "+" in the literal itself, even if the applicable extension is LITERAL-.
This commit is contained in:
1 parent
2caea0cf64
commit
6d7fc4cf25
2 files changed
+7
-10
No files matched your search
@@ -45,10 +45,8 @@ extension EncodeBuffer {
|
||||
return writeString("{\(bytes.count)}\r\n") + writeBytes(bytes)
|
||||
case .clientSynchronizingLiteral:
|
||||
return writeString("{\(bytes.count)}\r\n") + markStopPoint() + writeBytes(bytes)
|
||||
case .clientNonSynchronizingLiteralPlus:
|
||||
case .clientNonSynchronizingLiteral:
|
||||
return writeString("{\(bytes.count)+}\r\n") + writeBytes(bytes)
|
||||
case .clientNonSynchronizingLiteralMinus:
|
||||
return writeString("{\(bytes.count)-}\r\n") + writeBytes(bytes)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -60,9 +58,7 @@ extension EncodeBuffer {
|
||||
/// `{7}CRLF` + `foo bar`
|
||||
case clientSynchronizingLiteral
|
||||
/// `{7+}CRLFfoo bar`
|
||||
case clientNonSynchronizingLiteralPlus
|
||||
/// `{7-}CRLFfoo bar`
|
||||
case clientNonSynchronizingLiteralMinus
|
||||
case clientNonSynchronizingLiteral
|
||||
}
|
||||
|
||||
private func stringEncoding<T: Collection>(for bytes: T) -> StringEncoding where T.Element == UInt8 {
|
||||
@@ -70,10 +66,10 @@ extension EncodeBuffer {
|
||||
case .client(options: let options):
|
||||
if options.useQuotedString, canUseQuotedString(for: bytes) {
|
||||
return .quotedString
|
||||
} else if options.useNonSynchronizingLiteralMinus, bytes.count <= 4096 {
|
||||
return .clientNonSynchronizingLiteralMinus
|
||||
} else if options.useNonSynchronizingLiteralPlus {
|
||||
return .clientNonSynchronizingLiteralPlus
|
||||
return .clientNonSynchronizingLiteral
|
||||
} else if options.useNonSynchronizingLiteralMinus, bytes.count <= 4096 {
|
||||
return .clientNonSynchronizingLiteral
|
||||
} else {
|
||||
return .clientSynchronizingLiteral
|
||||
}
|
||||
|
||||
@@ -39,7 +39,8 @@ extension ByteBufferWriteLiteralTests {
|
||||
["{71}\r\n", "01234567890123456789012345678901234567890123456789012345678901234567890"],
|
||||
#line
|
||||
),
|
||||
(ByteBuffer(string: String(repeating: "a", count: 4096)), .literalMinus, ["{4096-}\r\n" + String(repeating: "a", count: 4096)], #line),
|
||||
(ByteBuffer(string: String(repeating: "a", count: 100)), .literalMinus, ["{100+}\r\n" + String(repeating: "a", count: 100)], #line),
|
||||
(ByteBuffer(string: String(repeating: "a", count: 4096)), .literalMinus, ["{4096+}\r\n" + String(repeating: "a", count: 4096)], #line),
|
||||
(ByteBuffer(string: String(repeating: "a", count: 4097)), .literalMinus, ["{4097}\r\n", String(repeating: "a", count: 4097)], #line),
|
||||
]
|
||||
self.iterateInputs(inputs: inputs, encoder: { self.testBuffer.writeIMAPString($0) })
|
||||
|
||||
Reference in new issue
Block a user