mirror of
https://github.com/passepartoutvpn/wireguard-apple.git
synced 2025-01-31 13:02:08 +00:00
Config file parsing: Fix bug when there are comments at the end
Signed-off-by: Roopesh Chander <roop@roopc.net>
This commit is contained in:
parent
2fe9f83ba5
commit
812e660491
@ -54,10 +54,9 @@ extension TunnelConfiguration {
|
|||||||
}
|
}
|
||||||
|
|
||||||
trimmedLine = trimmedLine.trimmingCharacters(in: .whitespaces)
|
trimmedLine = trimmedLine.trimmingCharacters(in: .whitespaces)
|
||||||
|
let lowercasedLine = trimmedLine.lowercased()
|
||||||
|
|
||||||
guard !trimmedLine.isEmpty else { continue }
|
if !trimmedLine.isEmpty {
|
||||||
let lowercasedLine = line.lowercased()
|
|
||||||
|
|
||||||
if let equalsIndex = line.firstIndex(of: "=") {
|
if let equalsIndex = line.firstIndex(of: "=") {
|
||||||
// Line contains an attribute
|
// Line contains an attribute
|
||||||
let keyWithCase = line[..<equalsIndex].trimmingCharacters(in: .whitespaces)
|
let keyWithCase = line[..<equalsIndex].trimmingCharacters(in: .whitespaces)
|
||||||
@ -87,6 +86,7 @@ extension TunnelConfiguration {
|
|||||||
} else if lowercasedLine != "[interface]" && lowercasedLine != "[peer]" {
|
} else if lowercasedLine != "[interface]" && lowercasedLine != "[peer]" {
|
||||||
throw ParseError.invalidLine(line)
|
throw ParseError.invalidLine(line)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
let isLastLine = lineIndex == lines.count - 1
|
let isLastLine = lineIndex == lines.count - 1
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user