]> git.ipfire.org Git - thirdparty/wireguard-apple.git/commitdiff
wg-quick conf parser: Handle inline comments correctly
authorRoopesh Chander <roop@roopc.net>
Tue, 5 Feb 2019 11:15:32 +0000 (16:45 +0530)
committerRoopesh Chander <roop@roopc.net>
Tue, 5 Feb 2019 11:15:32 +0000 (16:45 +0530)
Signed-off-by: Roopesh Chander <roop@roopc.net>
WireGuard/Shared/Model/TunnelConfiguration+WgQuickConfig.swift

index 65676f565b6a2b196cdc9f9f95cb5d3ea290c36c..fa32de2eedd1908d1d7eda5971680aacdda58b38 100644 (file)
@@ -57,11 +57,11 @@ extension TunnelConfiguration {
             let lowercasedLine = trimmedLine.lowercased()
 
             if !trimmedLine.isEmpty {
-                if let equalsIndex = line.firstIndex(of: "=") {
+                if let equalsIndex = trimmedLine.firstIndex(of: "=") {
                     // Line contains an attribute
-                    let keyWithCase = line[..<equalsIndex].trimmingCharacters(in: .whitespaces)
+                    let keyWithCase = trimmedLine[..<equalsIndex].trimmingCharacters(in: .whitespaces)
                     let key = keyWithCase.lowercased()
-                    let value = line[line.index(equalsIndex, offsetBy: 1)...].trimmingCharacters(in: .whitespaces)
+                    let value = trimmedLine[trimmedLine.index(equalsIndex, offsetBy: 1)...].trimmingCharacters(in: .whitespaces)
                     let keysWithMultipleEntriesAllowed: Set<String> = ["address", "allowedips", "dns"]
                     if let presentValue = attributes[key] {
                         if keysWithMultipleEntriesAllowed.contains(key) {