diff options
author | Roopesh Chander <roop@roopc.net> | 2018-11-06 22:32:10 +0530 |
---|---|---|
committer | Roopesh Chander <roop@roopc.net> | 2018-11-06 22:32:33 +0530 |
commit | 3496adca867aec9564c7418bb378c92191a58a9b (patch) | |
tree | c5e94fcad2f0457697802049ae422b3a5beef7c8 | |
parent | wireguard-go-bridge: take fd instead of fnptr (diff) | |
download | wireguard-apple-3496adca867aec9564c7418bb378c92191a58a9b.tar.xz wireguard-apple-3496adca867aec9564c7418bb378c92191a58a9b.zip |
Importing: Error out on file with unsupported file extension
Signed-off-by: Roopesh Chander <roop@roopc.net>
-rw-r--r-- | WireGuard/WireGuard/UI/iOS/TunnelsListTableViewController.swift | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/WireGuard/WireGuard/UI/iOS/TunnelsListTableViewController.swift b/WireGuard/WireGuard/UI/iOS/TunnelsListTableViewController.swift index 7e06bce..bd067c8 100644 --- a/WireGuard/WireGuard/UI/iOS/TunnelsListTableViewController.swift +++ b/WireGuard/WireGuard/UI/iOS/TunnelsListTableViewController.swift @@ -240,6 +240,8 @@ class TunnelsListTableViewController: UIViewController { self?.showErrorAlert(title: "Created \(numberSuccessful) tunnels", message: "Created \(numberSuccessful) of \(unarchivedFiles.count) tunnels from zip archive") } + } else { + fatalError("Unsupported file extension") } } } @@ -249,7 +251,13 @@ class TunnelsListTableViewController: UIViewController { extension TunnelsListTableViewController: UIDocumentPickerDelegate { func documentPicker(_ controller: UIDocumentPickerViewController, didPickDocumentsAt urls: [URL]) { if let url = urls.first { - importFromFile(url: url) + if (url.pathExtension == "conf" || url.pathExtension == "zip") { + importFromFile(url: url) + } else { + // What if a file provider extension didn't respect our 'documentTypes' parameter + self.showErrorAlert(title: "Invalid file extension", + message: "Please select a WireGuard configuration file (.conf) or a zip archive (.zip) for importing") + } } } } |