cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From purplecabb...@apache.org
Subject [03/12] cordova-plugin-file git commit: Handle url's containing absolute windows path starting with drive letter and colon (encoded as %3A) through root FS
Date Fri, 23 Jan 2015 20:19:20 GMT
Handle url's containing absolute windows path starting with drive letter and colon (encoded
as %3A) through root FS


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/f8f35b1c
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/tree/f8f35b1c
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/diff/f8f35b1c

Branch: refs/heads/master
Commit: f8f35b1c21949697fe656db501e340f7b77eeca2
Parents: 7c15bf0
Author: Vladimir Avdonin <vldmrrr@gmail.com>
Authored: Tue Nov 4 18:23:10 2014 -0600
Committer: Vladimir Avdonin <vldmrrr@gmail.com>
Committed: Tue Nov 4 18:23:10 2014 -0600

----------------------------------------------------------------------
 src/windows/FileProxy.js | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/blob/f8f35b1c/src/windows/FileProxy.js
----------------------------------------------------------------------
diff --git a/src/windows/FileProxy.js b/src/windows/FileProxy.js
index e4d5b4d..44e6312 100644
--- a/src/windows/FileProxy.js
+++ b/src/windows/FileProxy.js
@@ -71,9 +71,10 @@ function nativePathToCordova(path) {
     return cleanPath;
 }
 
+var driveRE = new RegExp("^[/]*([A-Z]:)");
 var invalidNameRE = /[\\?*|"<>:]/;
 function validName(name) {
-	return !invalidNameRE.test(name);
+    return !invalidNameRE.test(name.replace(driveRE,''));
 }
 
 var slashesRE = new RegExp('/{2,}','g');
@@ -88,10 +89,10 @@ var WinFS = function(name, root) {
         this.winpath += "/";
     }
     this.makeNativeURL = function(path) {
-    	return encodeURI(this.root.nativeURL + sanitize(path));};
+        return encodeURI(this.root.nativeURL + sanitize(path.replace(':','%3A')));};
 	root.fullPath = '/';
 	if (!root.nativeURL)
-		root.nativeURL = 'file://'+sanitize(this.winpath + root.fullPath);
+            root.nativeURL = 'file://'+sanitize(this.winpath + root.fullPath).replace(':','%3A');
 	WinFS.__super__.constructor.call(this, name, root);
 };
 
@@ -125,7 +126,7 @@ function getAllFS() {
 			Object.freeze(new WinFS('root', { 
 				name: 'root', 
 				//nativeURL: 'file:///'
-				winpath: '/'
+				winpath: ''
 			}))
 		};
 	}
@@ -181,7 +182,7 @@ function pathFromURL(url) {
 		}
 	});
 	
-	return path;
+	return path.replace('%3A',':').replace(driveRE,'$1');
 }
 
 function getFilesystemFromURL(url) {
@@ -1095,7 +1096,9 @@ module.exports = {
         	fail(FileError.ENCODING_ERR);
         	return;
         }
-		var abspath = cordovaPathToNative(fs.winpath+path);
+        if (path.indexOf(fs.winpath) === 0)
+            path=path.substr(fs.winpath.length);
+        var abspath = cordovaPathToNative(fs.winpath+path);
 		
         getFileFromPathAsync(abspath).done(
             function (storageFile) {


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org


Mime
View raw message