Skip to content

Commit

Permalink
Fix file URL double-encoding
Browse files Browse the repository at this point in the history
If the file URL contains percent encoding then the percent encodings are re-encoded, as we treat the already encoded string as a path, so NSURL re-encodes it. We can assume that if the string begins file:// that it is a legal file URL, in which case we can simply use [NSURL URLWithString].
  • Loading branch information
karlvr committed Feb 18, 2019
1 parent 091df26 commit d00a8cf
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions src/ios/SocialSharing.m
Original file line number Diff line number Diff line change
Expand Up @@ -742,8 +742,7 @@ -(NSURL*)getFile: (NSString *)fileName {
NSString *fullPath = [NSString stringWithFormat:@"%@/%@", bundlePath, fileName];
file = [NSURL fileURLWithPath:fullPath];
} else if ([fileName hasPrefix:@"file://"]) {
// stripping the first 6 chars, because the path should start with / instead of file://
file = [NSURL fileURLWithPath:[fileName substringFromIndex:6]];
file = [NSURL URLWithString:fileName];
} else if (rangeData.location != NSNotFound ){
//If found "data:"
NSString *fileType = (NSString*)[[[fileName substringFromIndex:rangeData.location+rangeData.length] componentsSeparatedByString: @";"] objectAtIndex:0];
Expand Down

0 comments on commit d00a8cf

Please sign in to comment.