From 0a3a5ee900336eb96fc72f6fbfec18091e4b873a Mon Sep 17 00:00:00 2001 From: Roopesh Chander Date: Sat, 9 Feb 2019 19:24:08 +0530 Subject: Importing: Ignore case in matching file extensions inside zip files Signed-off-by: Roopesh Chander --- WireGuard/WireGuard/ZipArchive/ZipArchive.swift | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'WireGuard/WireGuard/ZipArchive') diff --git a/WireGuard/WireGuard/ZipArchive/ZipArchive.swift b/WireGuard/WireGuard/ZipArchive/ZipArchive.swift index 9e28dc2..2cca880 100644 --- a/WireGuard/WireGuard/ZipArchive/ZipArchive.swift +++ b/WireGuard/WireGuard/ZipArchive/ZipArchive.swift @@ -42,6 +42,7 @@ class ZipArchive { static func unarchive(url: URL, requiredFileExtensions: [String]) throws -> [(fileBaseName: String, contents: Data)] { var results = [(fileBaseName: String, contents: Data)]() + var requiredFileExtensionsLowercased = requiredFileExtensions.map { $0.lowercased() } guard let zipFile = unzOpen64(url.path) else { throw ZipArchiveError.cantOpenInputZipFile @@ -70,7 +71,7 @@ class ZipArchive { let isDirectory = (lastChar == "/" || lastChar == "\\") let fileURL = URL(fileURLWithFileSystemRepresentation: fileNameBuffer, isDirectory: isDirectory, relativeTo: nil) - if !isDirectory && requiredFileExtensions.contains(fileURL.pathExtension) { + if !isDirectory && requiredFileExtensionsLowercased.contains(fileURL.pathExtension.lowercased()) { var unzippedData = Data() var bytesRead: Int32 = 0 repeat { -- cgit v1.2.3-59-g8ed1b