Skip to content

Commit

Permalink
Merge pull request #42 from mRs-/master
Browse files Browse the repository at this point in the history
[BUGFIX] Critical! String Encoding Bugfix
  • Loading branch information
garrettmoon committed Nov 19, 2015
2 parents 935d4be + 3391c57 commit b0e0016
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion PINCache/PINDiskCache.m
Expand Up @@ -143,7 +143,7 @@ - (NSString *)encodedString:(NSString *)string
{
if (![string length])
return @"";
return [string stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet characterSetWithCharactersInString:@".:/"]];
return [string stringByAddingPercentEncodingWithAllowedCharacters:[[NSCharacterSet characterSetWithCharactersInString:@".:/"] invertedSet]];
}

- (NSString *)decodedString:(NSString *)string
Expand Down
12 changes: 12 additions & 0 deletions tests/PINCacheTests/PINCacheTests.m
Expand Up @@ -8,6 +8,12 @@
NSString * const PINCacheTestName = @"PINCacheTest";
NSTimeInterval PINCacheTestBlockTimeout = 5.0;

@interface PINDiskCache()

- (NSString *)encodedString:(NSString *)string;

@end

@interface PINCacheTests ()
@property (strong, nonatomic) PINCache *cache;
@end
Expand Down Expand Up @@ -62,6 +68,12 @@ - (dispatch_time_t)timeout

#pragma mark - Tests -

- (void)testDiskCacheStringEncoding
{
NSString *string = [self.cache.diskCache encodedString:@"http://www.test.de-<CoolStuff>"];
XCTAssertTrue([string isEqualToString:@"http%3A%2F%2Fwww%2Etest%2Ede-<CoolStuff>"]);
}

- (void)testCoreProperties
{
PINCache *cache = [[PINCache alloc] initWithName:PINCacheTestName];
Expand Down

0 comments on commit b0e0016

Please sign in to comment.