aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2019-06-28 12:26:39 +0200
committerJason A. Donenfeld <Jason@zx2c4.com>2019-06-28 12:26:39 +0200
commitbb5760cca4d8bc844aa0c017958d3dbea7005f2f (patch)
treecd2d67dba3e6a5cacae84da179162a49e56d4b0e
parentUI: macOS: Show useful error message on .conf import (diff)
downloadwireguard-apple-bb5760cca4d8bc844aa0c017958d3dbea7005f2f.tar.xz
wireguard-apple-bb5760cca4d8bc844aa0c017958d3dbea7005f2f.zip
WgQuickConfig: Swift treats \r\n as a single character
let blah = "hello\nworld\ndoes\nthis\nwork" print(blah.split(separator: "\n")) //output: ["hello", "world", "does", "this", "work"] let blah2 = "hello\r\nworld\r\ndoes\r\nthis\r\nwork" print(blah2.split(separator: "\n")) //output: ["hello\r\nworld\r\ndoes\r\nthis\r\nwork"] //expected: ["hello\r", "world\r", "does\r", "this\r", "work\r"] In blah2, the string splitting fails because swift considers \r\n to be its own character. Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
-rw-r--r--WireGuard/Shared/Model/TunnelConfiguration+WgQuickConfig.swift2
1 files changed, 1 insertions, 1 deletions
diff --git a/WireGuard/Shared/Model/TunnelConfiguration+WgQuickConfig.swift b/WireGuard/Shared/Model/TunnelConfiguration+WgQuickConfig.swift
index 6aba0ac7..5e8f969f 100644
--- a/WireGuard/Shared/Model/TunnelConfiguration+WgQuickConfig.swift
+++ b/WireGuard/Shared/Model/TunnelConfiguration+WgQuickConfig.swift
@@ -39,7 +39,7 @@ extension TunnelConfiguration {
var interfaceConfiguration: InterfaceConfiguration?
var peerConfigurations = [PeerConfiguration]()
- let lines = wgQuickConfig.split(separator: "\n")
+ let lines = wgQuickConfig.split { $0.isNewline }
var parserState = ParserState.notInASection
var attributes = [String: String]()