CB-10696 iOS: Encode target path with spaces

This commit is contained in:
Nikita Matrosov
2017-04-06 16:24:26 +03:00
parent e95238e1f5
commit e9d93c0a54
2 changed files with 51 additions and 0 deletions
+10
View File
@@ -440,6 +440,13 @@ static CFIndex WriteDataToStream(NSData* data, CFWriteStreamRef stream)
targetURL = [[self.commandDelegate getCommandInstance:@"File"] fileSystemURLforLocalPath:target].url;
} else {
targetURL = [NSURL URLWithString:target];
if (targetURL == nil) {
NSString* targetUrlTextEscaped = [target stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLFragmentAllowedCharacterSet]];
if (targetUrlTextEscaped) {
targetURL = [NSURL URLWithString:targetUrlTextEscaped];
}
}
}
NSURL* sourceURL = [NSURL URLWithString:source];
@@ -447,6 +454,9 @@ static CFIndex WriteDataToStream(NSData* data, CFWriteStreamRef stream)
if (!sourceURL) {
errorCode = INVALID_URL_ERR;
NSLog(@"File Transfer Error: Invalid server URL %@", source);
} else if (!targetURL) {
errorCode = INVALID_URL_ERR;
NSLog(@"File Tranfer Error: Invalid target URL %@", target);
} else if (![targetURL isFileURL]) {
CDVFilesystemURL *fsURL = [CDVFilesystemURL fileSystemURLWithString:target];
if (!fsURL) {