Skip to content

Commit

Permalink
Fixes ajaxorg/cloud9infra#2766
Browse files Browse the repository at this point in the history
  • Loading branch information
sergi committed Sep 28, 2012
1 parent bee19ea commit 6eac748
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions lib/DAV/tree/ftp.js
Expand Up @@ -143,12 +143,20 @@ exports.jsDAV_Tree_Ftp = jsDAV_Tree_Ftp;
* @return {String} * @return {String}
*/ */
this.getRealPath = function(path) { this.getRealPath = function(path) {
var re = new RegExp("^" + this.basePath); var _basePath = Util.rtrim(this.basePath);
if (path.match(re)) { 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; return path;
} }
else { else {
return Path.normalize(Path.join(this.basePath, path)); return Path.normalize(Path.join(_basePath, _path));
} }
}; };


Expand Down Expand Up @@ -190,7 +198,7 @@ exports.jsDAV_Tree_Ftp = jsDAV_Tree_Ftp;
var node = this.ftp.$cache[source]; var node = this.ftp.$cache[source];
var ftp = this.ftp; var ftp = this.ftp;


if (!node) if (!node)
return next(new Error("Node not found for path " + source)); return next(new Error("Node not found for path " + source));


node.setName(destination, function(err) { node.setName(destination, function(err) {
Expand Down

0 comments on commit 6eac748

Please sign in to comment.