Skip to content

Commit

Permalink
Sanitize storage key. Fixes #38
Browse files Browse the repository at this point in the history
  • Loading branch information
JanGorman committed Oct 22, 2016
1 parent 336e795 commit 17df49f
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
4 changes: 3 additions & 1 deletion Library/MapleBacon/MapleBacon/Storage/DiskStorage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ extension DiskStorage: Storage {
}

public func image(forKey key: String) -> UIImage? {
guard let data = try? Data(contentsOf: URL(fileURLWithPath: defaultStoragePath(forKey: key))) else { return nil }
let path = defaultStoragePath(forKey: key)
guard let data = try? Data(contentsOf: URL(fileURLWithPath: path)) else { return nil }
return UIImage.imageWithCachedData(data)
}

Expand Down Expand Up @@ -71,6 +72,7 @@ extension DiskStorage: Storage {
}

fileprivate func defaultStoragePath(forKey key: String) -> String {
let key = key.components(separatedBy: .punctuationCharacters).joined()
return (storagePath as NSString).appendingPathComponent(key)
}

Expand Down
2 changes: 1 addition & 1 deletion MapleBacon.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = "MapleBacon"
s.version = "3.0.0"
s.version = "3.0.1"
s.summary = "A delicious image download and caching library for iOS"
s.description = <<-DESC
A delicious image download and caching library for iOS. Background downloads, caching and scaling.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
BlueprintIdentifier = "F2AB726D1A40395200CCE62B"
BuildableName = "MapleBaconExample.app"
BlueprintName = "MapleBaconExample"
ReferencedContainer = "container:../../MapleBaconExample/MapleBaconExample.xcodeproj">
ReferencedContainer = "container:MapleBaconExample/MapleBaconExample.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
Expand All @@ -92,7 +92,7 @@
BlueprintIdentifier = "F2AB726D1A40395200CCE62B"
BuildableName = "MapleBaconExample.app"
BlueprintName = "MapleBaconExample"
ReferencedContainer = "container:../../MapleBaconExample/MapleBaconExample.xcodeproj">
ReferencedContainer = "container:MapleBaconExample/MapleBaconExample.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
<AdditionalOptions>
Expand Down

0 comments on commit 17df49f

Please sign in to comment.