Merge remote-tracking branch 'origin/ci-fix-tar-k-flag' into preview-fix-invalid-characters-in-header

pull/315/head
Tim Robinson 2016-06-13 18:36:14 +00:00
commit 3751e2a7c8
4 zmienionych plików z 30 dodań i 21 usunięć

Wyświetl plik

@ -1,7 +1,7 @@
{ {
"name": "c9", "name": "c9",
"description": "New Cloud9 Client", "description": "New Cloud9 Client",
"version": "3.1.2672", "version": "3.1.2708",
"author": "Ajax.org B.V. <info@ajax.org>", "author": "Ajax.org B.V. <info@ajax.org>",
"private": true, "private": true,
"main": "bin/c9", "main": "bin/c9",
@ -58,11 +58,11 @@
"c9" "c9"
], ],
"c9plugins": { "c9plugins": {
"c9.ide.language": "#f62951109c", "c9.ide.language": "#0e86345d39",
"c9.ide.language.core": "#10a225e77d", "c9.ide.language.core": "#10a225e77d",
"c9.ide.language.css": "#46ad561506", "c9.ide.language.css": "#46ad561506",
"c9.ide.language.generic": "#b47cbe58f9", "c9.ide.language.generic": "#b47cbe58f9",
"c9.ide.language.html": "#8e990755bb", "c9.ide.language.html": "#cdc3960225",
"c9.ide.language.html.diff": "#7d6cecfb90", "c9.ide.language.html.diff": "#7d6cecfb90",
"c9.ide.language.javascript": "#b82f16e56a", "c9.ide.language.javascript": "#b82f16e56a",
"c9.ide.language.javascript.immediate": "#82c426dbca", "c9.ide.language.javascript.immediate": "#82c426dbca",
@ -71,7 +71,7 @@
"c9.ide.language.javascript.infer": "#b9c2e4bdb8", "c9.ide.language.javascript.infer": "#b9c2e4bdb8",
"c9.ide.language.jsonalyzer": "#a32369793c", "c9.ide.language.jsonalyzer": "#a32369793c",
"c9.ide.language.codeintel": "#4e0a272229", "c9.ide.language.codeintel": "#4e0a272229",
"c9.ide.collab": "#24e28024d7", "c9.ide.collab": "#e015881720",
"c9.ide.local": "#9169fec157", "c9.ide.local": "#9169fec157",
"c9.ide.find": "#a2dfc3e306", "c9.ide.find": "#a2dfc3e306",
"c9.ide.find.infiles": "#488db22ee1", "c9.ide.find.infiles": "#488db22ee1",

Wyświetl plik

@ -91,24 +91,30 @@ define(function(require, exports, module) {
} }
function downloadProject() { function downloadProject() {
vfs.download("/", info.getWorkspace().name + getArchiveFileExtension()); vfs.download("/", makeArchiveFilename(info.getWorkspace().name));
} }
function downloadPaths(paths) { function downloadPaths(paths) {
vfs.download(paths, info.getWorkspace().name + getArchiveFileExtension()); var lastPart = paths[0].match(/([^\/]*)\/?$/)[1];
var filename = lastPart ? (lastPart + "[+" + (paths.length - 1) + "]") : info.getWorkspace().name;
vfs.download(paths, makeArchiveFilename(filename));
} }
function downloadFolder(path) { function downloadFolder(path) {
var withTrailingSlash = path.replace(/\/*$/, "/"); var withTrailingSlash = path.replace(/\/*$/, "/");
var parts = withTrailingSlash.split("/"); var parts = withTrailingSlash.split("/");
var lastPart = parts[parts.length - 2]; var folderName = parts[parts.length - 2];
vfs.download(withTrailingSlash, lastPart + getArchiveFileExtension()); vfs.download(withTrailingSlash, makeArchiveFilename(folderName));
} }
function downloadFile(path) { function downloadFile(path) {
vfs.download(path.replace(/\/*$/, ""), null, true); vfs.download(path.replace(/\/*$/, ""), null, true);
} }
function makeArchiveFilename(filename) {
return filename + getArchiveFileExtension();
}
function getArchiveFileExtension() { function getArchiveFileExtension() {
var downloadFilesAs = settings.get(SETTING_PATH); var downloadFilesAs = settings.get(SETTING_PATH);
if (downloadFilesAs === 'auto' || !downloadFilesAs) { if (downloadFilesAs === 'auto' || !downloadFilesAs) {

Wyświetl plik

@ -198,7 +198,8 @@ define(function(require, exports, module) {
} }
window.open(vfsUrl(path) + extraPaths window.open(vfsUrl(path) + extraPaths
+ "?download" + "?download"
+ (filename ? "=" + escape(filename) : "") // Escape '+', otherwise it gets interpreted as a space.
+ (filename ? "=" + escape(filename) : "").replace(/\+/g, "%2B")
+ (isfile ? "&isfile=1" : "")); + (isfile ? "&isfile=1" : ""));
} }

Wyświetl plik

@ -44,11 +44,11 @@ define(function(require, exports, module) {
filename += (paths.length > 1 ? "[+" + (paths.length - 1) + "]" : "") + ".tar.gz"; filename += (paths.length > 1 ? "[+" + (paths.length - 1) + "]" : "") + ".tar.gz";
} }
} }
var filenameHeader = "attachment; filename*=utf-8''" + encodeURIComponent(filename); var filenameHeader = "attachment; filename*=utf-8''" + escape(filename);
var process; var proc;
req.on("close", function() { req.on("close", function() {
if (process) process.kill(); if (proc) proc.kill();
}); });
if (req.uri.query.isfile) { if (req.uri.query.isfile) {
@ -113,24 +113,26 @@ define(function(require, exports, module) {
paths.forEach(function(path) { paths.forEach(function(path) {
if (!path) return; if (!path) return;
path = Path.relative(cwd, path); path = Path.relative(cwd, path);
// tar misinterprets the Windows path separator as an escape sequence, so use forward slash. if (process.platform == "win32") {
if (Path.sep === '\\') { // Quote the path to escape unusual characters and spaces.
path = path.replace(/\\/g, '/'); // NB: Double quotes are illegal within the actual path on Windows.
path = '"' + path.replace(/"/g, "") + '"';
} }
args.push(path); args.push(path);
}); });
vfs.spawn(executable, { vfs.spawn(executable, {
args: args, args: args,
cwd: cwd cwd: cwd,
windowsVerbatimArguments: true // Prevents Node from escaping the double quotes added above.
}, function (err, meta) { }, function (err, meta) {
if (err) if (err)
return next(err); return next(err);
process = meta.process; proc = meta.process;
// once we receive data on stdout pipe it to the response // once we receive data on stdout pipe it to the response
process.stdout.once("data", function (data) { proc.stdout.once("data", function (data) {
if (res.headerSent) if (res.headerSent)
return; return;
@ -139,15 +141,15 @@ define(function(require, exports, module) {
"Content-Disposition": filenameHeader "Content-Disposition": filenameHeader
}); });
res.write(data); res.write(data);
process.stdout.pipe(res); proc.stdout.pipe(res);
}); });
var stderr = ""; var stderr = "";
process.stderr.on("data", function (data) { proc.stderr.on("data", function (data) {
stderr += data; stderr += data;
}); });
process.on("exit", function(code, signal) { proc.on("exit", function(code, signal) {
if (res.headerSent) if (res.headerSent)
return; return;