Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUGFIX] Critical! String Encoding Bugfix #42

Merged
merged 2 commits into from
Nov 19, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion PINCache/PINDiskCache.m
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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