Throw to exit PUSH_REPLY parsing on continuation

This commit is contained in:
Davide De Rosa 2019-03-22 11:58:30 +01:00
parent 23b6e3b98e
commit 380ac2beac
2 changed files with 20 additions and 0 deletions

View File

@ -106,6 +106,10 @@ public class ConfigurationParser {
static let externalFiles = NSRegularExpression("^(ca|cert|key|tls-auth|tls-crypt) ")
static let connection = NSRegularExpression("^<connection>")
// MARK: Continuation
static let continuation = NSRegularExpression("^push-continuation [12]")
}
private enum Topology: String {
@ -232,6 +236,16 @@ public class ConfigurationParser {
isHandled = true
}
// MARK: Continuation
var isContinuation = false
Regex.continuation.enumerateArguments(in: line) {
isContinuation = ($0.first == "2")
}
guard !isContinuation else {
throw SessionError.continuationPushReply
}
// MARK: Inline content
if unsupportedError == nil {

View File

@ -59,6 +59,12 @@ public enum SessionError: String, Error {
/// The provided credentials failed authentication.
case badCredentials
/// The PUSH_REPLY is multipart.
case continuationPushReply
/// The reply to PUSH_REQUEST is malformed.
case malformedPushReply
/// A write operation failed at the link layer (e.g. network unreachable).
case failedLinkWrite