From 68533b2d2e2ccad7c6e628c5f78f8e8ba2eb96af Mon Sep 17 00:00:00 2001 From: Karl von Randow Date: Mon, 18 Feb 2019 16:40:31 +1300 Subject: [PATCH] Fix file URL double-encoding 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]. --- src/ios/SocialSharing.m | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/ios/SocialSharing.m b/src/ios/SocialSharing.m index ecb71b50..9ec98001 100644 --- a/src/ios/SocialSharing.m +++ b/src/ios/SocialSharing.m @@ -778,8 +778,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];