diff options
author | Roopesh Chander <roop@roopc.net> | 2018-11-03 15:45:29 +0530 |
---|---|---|
committer | Roopesh Chander <roop@roopc.net> | 2018-11-03 15:45:29 +0530 |
commit | 366ca7802af8f1f77f41ecf91fd32f8bf3cee082 (patch) | |
tree | 2cf1145e499842dc37097d0c8710beee5126e8b6 /WireGuard/WireGuard/UI/iOS/TunnelsListTableViewController.swift | |
parent | Zip archive: Handle files within folders inside the zip (diff) | |
download | wireguard-apple-366ca7802af8f1f77f41ecf91fd32f8bf3cee082.tar.xz wireguard-apple-366ca7802af8f1f77f41ecf91fd32f8bf3cee082.zip |
Ensure that all tunnel names are trimmed of whitespaces
Signed-off-by: Roopesh Chander <roop@roopc.net>
Diffstat (limited to 'WireGuard/WireGuard/UI/iOS/TunnelsListTableViewController.swift')
-rw-r--r-- | WireGuard/WireGuard/UI/iOS/TunnelsListTableViewController.swift | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/WireGuard/WireGuard/UI/iOS/TunnelsListTableViewController.swift b/WireGuard/WireGuard/UI/iOS/TunnelsListTableViewController.swift index e42b964..df509a6 100644 --- a/WireGuard/WireGuard/UI/iOS/TunnelsListTableViewController.swift +++ b/WireGuard/WireGuard/UI/iOS/TunnelsListTableViewController.swift @@ -179,7 +179,7 @@ class TunnelsListTableViewController: UIViewController { func importFromFile(url: URL) { // Import configurations from a .conf or a .zip file if (url.pathExtension == "conf") { - let fileBaseName = url.deletingPathExtension().lastPathComponent + let fileBaseName = url.deletingPathExtension().lastPathComponent.trimmingCharacters(in: .whitespacesAndNewlines) if let fileContents = try? String(contentsOf: url), let tunnelConfiguration = try? WgQuickConfigFileParser.parse(fileContents, name: fileBaseName) { tunnelsManager?.add(tunnelConfiguration: tunnelConfiguration) { (tunnel, error) in @@ -206,7 +206,8 @@ class TunnelsListTableViewController: UIViewController { } for (i, unarchivedFile) in unarchivedFiles.enumerated().reversed() { - if let trimmedName = URL(string: unarchivedFile.fileName)?.deletingPathExtension().lastPathComponent, !trimmedName.isEmpty { + let fileBaseName = URL(string: unarchivedFile.fileName)?.deletingPathExtension().lastPathComponent + if let trimmedName = fileBaseName?.trimmingCharacters(in: .whitespacesAndNewlines), !trimmedName.isEmpty { unarchivedFiles[i].fileName = trimmedName } else { unarchivedFiles.remove(at: i) |