You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@cordova.apache.org by "Vladimir Avdonin (JIRA)" <ji...@apache.org> on 2014/06/05 18:20:01 UTC

[jira] [Updated] (CB-6883) iOS: fileSystemURLforArg returns nil for file:// url with spaces

     [ https://issues.apache.org/jira/browse/CB-6883?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Vladimir Avdonin updated CB-6883:
---------------------------------

    Description: 
For file:// url with spaces, such as any path on iphone simulator, fileSystemURLforArg returns nil. The following change fix the issue:

diff --git a/src/ios/CDVFile.m b/src/ios/CDVFile.m
index b22b7cf..2b3a567 100644
--- a/src/ios/CDVFile.m
+++ b/src/ios/CDVFile.m
@@ -348,7 +348,8 @@ NSString* const kCDVFilesystemURLPrefix = @"cdvfile";
     CDVFilesystemURL* ret = nil;
     if ([urlArg hasPrefix:@"file://"]) {
         /* This looks like a file url. Get the path, and see if any handlers recognize it. */
-        NSURL *fileURL = [NSURL URLWithString:urlArg];
+        NSString* webStringURL = [urlArg stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
+        NSURL *fileURL = [NSURL URLWithString:webStringURL];
         NSURL *resolvedFileURL = [fileURL URLByResolvingSymlinksInPath];
         NSString *path = [resolvedFileURL path];
         ret = [self fileSystemURLforLocalPath:path];


  was:
For file:// url with spaces, such as any path on iphone simulator, fileSystemURLforArg returns nil. The following change fix the issue:

index b22b7cf..2b3a567 100644
--- a/src/ios/CDVFile.m
+++ b/src/ios/CDVFile.m
@@ -348,7 +348,8 @@ NSString* const kCDVFilesystemURLPrefix = @"cdvfile";
     CDVFilesystemURL* ret = nil;
     if ([urlArg hasPrefix:@"file://"]) {
         /* This looks like a file url. Get the path, and see if any handlers re
-        NSURL *fileURL = [NSURL URLWithString:urlArg];
+        NSString* webStringURL = [urlArg stringByAddingPercentEscapesUsingEncod
+        NSURL *fileURL = [NSURL URLWithString:webStringURL];
         NSURL *resolvedFileURL = [fileURL URLByResolvingSymlinksInPath];
         NSString *path = [resolvedFileURL path];
         ret = [self fileSystemURLforLocalPath:path];



> iOS: fileSystemURLforArg returns nil for file:// url with spaces 
> -----------------------------------------------------------------
>
>                 Key: CB-6883
>                 URL: https://issues.apache.org/jira/browse/CB-6883
>             Project: Apache Cordova
>          Issue Type: Bug
>          Components: Plugin File
>    Affects Versions: 3.5.0
>         Environment: iOs
>            Reporter: Vladimir Avdonin
>
> For file:// url with spaces, such as any path on iphone simulator, fileSystemURLforArg returns nil. The following change fix the issue:
> diff --git a/src/ios/CDVFile.m b/src/ios/CDVFile.m
> index b22b7cf..2b3a567 100644
> --- a/src/ios/CDVFile.m
> +++ b/src/ios/CDVFile.m
> @@ -348,7 +348,8 @@ NSString* const kCDVFilesystemURLPrefix = @"cdvfile";
>      CDVFilesystemURL* ret = nil;
>      if ([urlArg hasPrefix:@"file://"]) {
>          /* This looks like a file url. Get the path, and see if any handlers recognize it. */
> -        NSURL *fileURL = [NSURL URLWithString:urlArg];
> +        NSString* webStringURL = [urlArg stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
> +        NSURL *fileURL = [NSURL URLWithString:webStringURL];
>          NSURL *resolvedFileURL = [fileURL URLByResolvingSymlinksInPath];
>          NSString *path = [resolvedFileURL path];
>          ret = [self fileSystemURLforLocalPath:path];



--
This message was sent by Atlassian JIRA
(v6.2#6252)