Skip to content

Commit c3f966b

Browse files
committed
Escape all arguments when concatenating
1 parent 647ae92 commit c3f966b

File tree

3 files changed

+16
-8
lines changed

3 files changed

+16
-8
lines changed

packed/index.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ function cmake_configure_build(args) {
268268
var configure_command;
269269
return __generator(this, function (_a) {
270270
core.debug("configure_args: ".concat(configure_args));
271-
configure_command = configure_args.join(" ");
271+
configure_command = (0, util_1.command_arglist_to_string)(configure_args);
272272
core.debug("configure_command: ".concat(configure_command));
273273
args.executor.run(configure_command, true);
274274
return [2 /*return*/];
@@ -280,7 +280,7 @@ function cmake_configure_build(args) {
280280
var build_command;
281281
return __generator(this, function (_a) {
282282
core.debug("build_args: ".concat(build_args));
283-
build_command = build_args.join(" ");
283+
build_command = (0, util_1.command_arglist_to_string)(build_args);
284284
core.debug("build_command: ".concat(build_command));
285285
args.executor.run(build_command, true);
286286
return [2 /*return*/];
@@ -292,7 +292,7 @@ function cmake_configure_build(args) {
292292
var install_command;
293293
return __generator(this, function (_a) {
294294
core.debug("install_args: ".concat(install_args));
295-
install_command = install_args.join(" ");
295+
install_command = (0, util_1.command_arglist_to_string)(install_args);
296296
core.debug("install_command: ".concat(install_command));
297297
args.executor.run(install_command, true);
298298
return [2 /*return*/];
@@ -1298,7 +1298,7 @@ var __extends = (this && this.__extends) || (function () {
12981298
};
12991299
})();
13001300
Object.defineProperty(exports, "__esModule", ({ value: true }));
1301-
exports.shlex_split = exports.SetupSdlError = void 0;
1301+
exports.command_arglist_to_string = exports.shlex_split = exports.SetupSdlError = void 0;
13021302
var shlex = __nccwpck_require__(5659);
13031303
var SetupSdlError = /** @class */ (function (_super) {
13041304
__extends(SetupSdlError, _super);
@@ -1321,6 +1321,10 @@ function shlex_split(text) {
13211321
}
13221322
}
13231323
exports.shlex_split = shlex_split;
1324+
function command_arglist_to_string(args) {
1325+
return args.map(function (s) { return "\"".concat(s, "\""); }).join(" ");
1326+
}
1327+
exports.command_arglist_to_string = command_arglist_to_string;
13241328

13251329

13261330
/***/ }),

src/main.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { Octokit } from "@octokit/rest";
1010
import AdmZip = require("adm-zip");
1111

1212
import { convert_git_branch_tag_to_hash } from "./repo";
13-
import { SetupSdlError, shlex_split } from "./util";
13+
import { SetupSdlError, command_arglist_to_string, shlex_split } from "./util";
1414
import * as pm from "./pm";
1515

1616
import { GitHubRelease, ReleaseDb, ReleaseType } from "./version";
@@ -207,19 +207,19 @@ async function cmake_configure_build(args: {
207207

208208
await core.group(`Configuring ${args.project} (CMake)`, async () => {
209209
core.debug(`configure_args: ${configure_args}`);
210-
const configure_command = configure_args.join(" ");
210+
const configure_command = command_arglist_to_string(configure_args);
211211
core.debug(`configure_command: ${configure_command}`);
212212
args.executor.run(configure_command, true);
213213
});
214214
await core.group(`Building ${args.project} (CMake)`, async () => {
215215
core.debug(`build_args: ${build_args}`);
216-
const build_command = build_args.join(" ");
216+
const build_command = command_arglist_to_string(build_args);
217217
core.debug(`build_command: ${build_command}`);
218218
args.executor.run(build_command, true);
219219
});
220220
await core.group(`Installing ${args.project} (CMake)`, async () => {
221221
core.debug(`install_args: ${install_args}`);
222-
const install_command = install_args.join(" ");
222+
const install_command = command_arglist_to_string(install_args);
223223
core.debug(`install_command: ${install_command}`);
224224
args.executor.run(install_command, true);
225225
});

src/util.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,7 @@ export function shlex_split(text: undefined | string): string[] {
1717
return shlex.split(text);
1818
}
1919
}
20+
21+
export function command_arglist_to_string(args: string[]): string {
22+
return args.map((s) => `"${s}"`).join(" ");
23+
}

0 commit comments

Comments
 (0)