Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Bug 531152 - Regression from fix for recursive path paste
  • Loading branch information
squarti committed Feb 14, 2018
1 parent ad344ce commit 1f7c43d
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions modules/orionode/lib/fileUtil.js
Expand Up @@ -551,17 +551,23 @@ exports.handleFilePOST = function(workspaceRoot, fileRoot, req, res, destFile, m
}
var project = {};
if (isNonWrite) {
var sourceFile = getFile(req, api.decodeURIComponent(sourceUrl.replace(new RegExp("^"+fileRoot), "")));
if (isParentOf(sourceFile.path, destFile.path)) {
return api.writeError(400, res, "The destination cannot be a descendent of the source location");
var regex = new RegExp("^"+fileRoot);
if (!regex.test(sourceUrl)) {
var err1 = new Error("Failed to move project: " + sourceUrl);
err1.code = 403;
return api.writeError(403, res, err1);
}
var sourceFile = getFile(req, api.decodeURIComponent(sourceUrl.replace(regex, "")));
return fs.stat(sourceFile.path, function(err, stats) {
if(err) {
if (err.code === 'ENOENT') {
return api.writeError(typeof err.code === 'number' || 404, res, 'File not found:' + sourceUrl);
}
return api.writeError(500, res, err);
}
if (isParentOf(sourceFile.path, destFile.path)) {
return api.writeError(400, res, "The destination cannot be a descendent of the source location");
}
if (isCopy) {
return copy(sourceFile.path, destFile.path)
.then(function() {
Expand Down

0 comments on commit 1f7c43d

Please sign in to comment.