diff --git a/.gitignore b/.gitignore index 8b9fea7f..f4434e57 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,4 @@ node_modules .DS_Store test/workspace/.vscode dist +jdt-language-server-latest.tar.gz diff --git a/package.json b/package.json index 2a28a4af..b35bad76 100644 --- a/package.json +++ b/package.json @@ -64,7 +64,8 @@ }, "stripe.projectName": { "type": "string", - "description": "the project name to read from for config (default \"default\")" + "description": "the project name to read from for config (default \"default\")", + "pattern": "^[a-zA-Z0-9_-\\s]+$" }, "stripe.telemetry.enabled": { "type": "boolean", diff --git a/src/stripeTerminal.ts b/src/stripeTerminal.ts index e78916f3..e3daa664 100644 --- a/src/stripeTerminal.ts +++ b/src/stripeTerminal.ts @@ -38,15 +38,18 @@ export class StripeTerminal { 'stripe', new vscode.ShellExecution(cliPath, [ command, - ...args.map((arg) => ({ - quoting: vscode.ShellQuoting.Strong, - value: arg, - })), - ...globalCLIFlags.map((arg) => ({ - quoting: vscode.ShellQuoting.Strong, - value: arg, - })), - ]) + ...args, + ...globalCLIFlags + ], + { + shellQuoting: { + escape: { + escapeChar: '\\', + charsToEscape: '&`|"\'', + } + } + } + ) )); } @@ -54,7 +57,10 @@ export class StripeTerminal { private getGlobalCLIFlags(): Array { const stripeConfig = vscode.workspace.getConfiguration('stripe'); - const projectName = stripeConfig.get('projectName', null); + let projectName = stripeConfig.get('projectName', null); + if (projectName !== null) { + projectName = projectName.replace(/[\\"'`]/g, ''); + } const projectNameFlag = projectName ? ['--project-name', projectName] : []; diff --git a/test/suite/stripeTerminal.test.ts b/test/suite/stripeTerminal.test.ts index 480c947d..0714756f 100644 --- a/test/suite/stripeTerminal.test.ts +++ b/test/suite/stripeTerminal.test.ts @@ -52,15 +52,17 @@ suite('stripeTerminal', function () { 'stripe', new vscode.ShellExecution(path, [ 'listen', - { - quoting: vscode.ShellQuoting.Strong, - value: '--forward-to' + '--forward-to', + 'localhost', + ], + { + shellQuoting: { + escape: { + escapeChar: '\\', + charsToEscape: '&`|"\'', + }, }, - { - quoting: vscode.ShellQuoting.Strong, - value: 'localhost' - } - ]) + }), ), ]); });