From 51b3931485015540feb91e3f1e2efe129b1b0092 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kornel=20Lesin=CC=81ski?= Date: Fri, 23 Dec 2016 19:59:48 +0100 Subject: [PATCH 1/2] Simpler suffix check --- Sparkle/SUPipedUnarchiver.m | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/Sparkle/SUPipedUnarchiver.m b/Sparkle/SUPipedUnarchiver.m index 971886a4..c1549475 100644 --- a/Sparkle/SUPipedUnarchiver.m +++ b/Sparkle/SUPipedUnarchiver.m @@ -37,17 +37,13 @@ @".tar.xz" : extractTXZ, @".txz" : extractTXZ, @".tar.lzma" : extractTXZ - }; + }; NSString *lastPathComponent = [path lastPathComponent]; for (NSString *currentType in extractCommandDictionary) { - NSArray *value = [extractCommandDictionary objectForKey:currentType]; - assert(value != nil); - - if ([currentType length] > [lastPathComponent length]) continue; - if ([[lastPathComponent substringFromIndex:[lastPathComponent length] - [currentType length]] isEqualToString:currentType]) { - return value; + if ([lastPathComponent hasSuffix:currentType]) { + return [extractCommandDictionary objectForKey:currentType]; } } return nil; From a1095ff29c5baf645cb0f0ada959ecbeeb76705f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kornel=20Lesin=CC=81ski?= Date: Fri, 23 Dec 2016 20:00:45 +0100 Subject: [PATCH 2/2] Null fix --- Tests/SUFileManagerTest.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tests/SUFileManagerTest.swift b/Tests/SUFileManagerTest.swift index 91c30afd..1f175a7a 100644 --- a/Tests/SUFileManagerTest.swift +++ b/Tests/SUFileManagerTest.swift @@ -12,7 +12,7 @@ class SUFileManagerTest: XCTestCase { func makeTempFiles(_ testBlock: (SUFileManager, URL, URL, URL, URL, URL, URL) -> Void) { - let fileManager = SUFileManager.default()! + let fileManager = SUFileManager.default() let tempDirectoryURL = (try! fileManager.makeTemporaryDirectory(withPreferredName: "Sparkle Unit Test Data", appropriateForDirectoryURL: URL(fileURLWithPath: NSHomeDirectory())))