From 3496adca867aec9564c7418bb378c92191a58a9b Mon Sep 17 00:00:00 2001 From: Roopesh Chander Date: Tue, 6 Nov 2018 22:32:10 +0530 Subject: Importing: Error out on file with unsupported file extension Signed-off-by: Roopesh Chander --- .../WireGuard/UI/iOS/TunnelsListTableViewController.swift | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'WireGuard/WireGuard') 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") + } } } } -- cgit v1.2.3-59-g8ed1b