Skip to content
Browse files

Fixes ajaxorg/cloud9infra#2766

  • Loading branch information...
1 parent bee19ea commit 6eac748fb42c4e2b1e32baf6939c01529c466c80 @sergi sergi committed
Showing with 12 additions and 4 deletions.
  1. +12 −4 lib/DAV/tree/ftp.js
View
16 lib/DAV/tree/ftp.js
@@ -143,12 +143,20 @@ exports.jsDAV_Tree_Ftp = jsDAV_Tree_Ftp;
* @return {String}
*/
this.getRealPath = function(path) {
- var re = new RegExp("^" + this.basePath);
- if (path.match(re)) {
+ var _basePath = Util.rtrim(this.basePath);
+ var _path = Util.trim(path).replace(/[\/]+$/, "");
+
+ var badEscape = _basePath.match(/\\+/);
+ if (badEscape && badEscape[0].length % 2 === 1) {
+ _basePath += "\\";
+ }
+
+ var re = new RegExp("^" + _basePath);
+ if (_path.match(re)) {
return path;
}
else {
- return Path.normalize(Path.join(this.basePath, path));
+ return Path.normalize(Path.join(_basePath, _path));
}
};
@@ -190,7 +198,7 @@ exports.jsDAV_Tree_Ftp = jsDAV_Tree_Ftp;
var node = this.ftp.$cache[source];
var ftp = this.ftp;
- if (!node)
+ if (!node)
return next(new Error("Node not found for path " + source));
node.setName(destination, function(err) {

0 comments on commit 6eac748

Please sign in to comment.
Something went wrong with that request. Please try again.