Skip to content

Commit b0e0016

Browse files
committed
Merge pull request #42 from mRs-/master
[BUGFIX] Critical! String Encoding Bugfix
2 parents 935d4be + 3391c57 commit b0e0016

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

PINCache/PINDiskCache.m

+1-1
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ - (NSString *)encodedString:(NSString *)string
143143
{
144144
if (![string length])
145145
return @"";
146-
return [string stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet characterSetWithCharactersInString:@".:/"]];
146+
return [string stringByAddingPercentEncodingWithAllowedCharacters:[[NSCharacterSet characterSetWithCharactersInString:@".:/"] invertedSet]];
147147
}
148148

149149
- (NSString *)decodedString:(NSString *)string

tests/PINCacheTests/PINCacheTests.m

+12
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,12 @@
88
NSString * const PINCacheTestName = @"PINCacheTest";
99
NSTimeInterval PINCacheTestBlockTimeout = 5.0;
1010

11+
@interface PINDiskCache()
12+
13+
- (NSString *)encodedString:(NSString *)string;
14+
15+
@end
16+
1117
@interface PINCacheTests ()
1218
@property (strong, nonatomic) PINCache *cache;
1319
@end
@@ -62,6 +68,12 @@ - (dispatch_time_t)timeout
6268

6369
#pragma mark - Tests -
6470

71+
- (void)testDiskCacheStringEncoding
72+
{
73+
NSString *string = [self.cache.diskCache encodedString:@"http://www.test.de-<CoolStuff>"];
74+
XCTAssertTrue([string isEqualToString:@"http%3A%2F%2Fwww%2Etest%2Ede-<CoolStuff>"]);
75+
}
76+
6577
- (void)testCoreProperties
6678
{
6779
PINCache *cache = [[PINCache alloc] initWithName:PINCacheTestName];

0 commit comments

Comments
 (0)