You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by ia...@apache.org on 2014/04/23 20:56:58 UTC

[02/37] git commit: CB-4952: ios: Resolve symlinks in file:// URLs

CB-4952: ios: Resolve symlinks in file:// URLs


Project: http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/commit/ee04e5c7
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/tree/ee04e5c7
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/diff/ee04e5c7

Branch: refs/heads/master
Commit: ee04e5c7c524b4bfcdd9a4f33475fc5a5c2c93b3
Parents: 8222033
Author: Ian Clelland <ic...@chromium.org>
Authored: Mon Mar 3 10:44:52 2014 -0500
Committer: Ian Clelland <ic...@chromium.org>
Committed: Mon Mar 3 10:44:52 2014 -0500

----------------------------------------------------------------------
 src/ios/CDVFile.m | 17 +++--------------
 1 file changed, 3 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/blob/ee04e5c7/src/ios/CDVFile.m
----------------------------------------------------------------------
diff --git a/src/ios/CDVFile.m b/src/ios/CDVFile.m
index fa4a0a2..d36fbe6 100644
--- a/src/ios/CDVFile.m
+++ b/src/ios/CDVFile.m
@@ -426,20 +426,9 @@ NSString* const kCDVFilesystemURLPrefix = @"cdvfile";
     /* Backwards-compatibility: Check for file:// urls */
     if ([localURIstr hasPrefix:@"file://"]) {
         /* This looks like a file url. Get the path, and see if any handlers recognize it. */
-        NSString* path;
-        NSRange questionMark = [localURIstr rangeOfString:@"?"];
-        NSUInteger pathEnd;
-        if (questionMark.location == NSNotFound) {
-            pathEnd = localURIstr.length;
-        } else {
-            pathEnd = questionMark.location;
-        }
-        NSRange thirdSlash = [localURIstr rangeOfString:@"/" options:0 range:(NSRange){7, pathEnd-7}];
-        if (thirdSlash.location == NSNotFound) {
-            path = @"";
-        } else {
-            path = [localURIstr substringWithRange:NSMakeRange(thirdSlash.location, pathEnd-thirdSlash.location)];
-        }
+        NSURL *fileURL = [NSURL URLWithString:localURIstr];
+        NSURL *resolvedFileURL = [fileURL URLByResolvingSymlinksInPath];
+        NSString *path = [resolvedFileURL path];
         inputURI = [self fileSystemURLforLocalPath:path];
     } else {
         inputURI = [CDVFilesystemURL fileSystemURLWithString:localURIstr];