diff --git a/node/test/toolrunnertests.ts b/node/test/toolrunnertests.ts index ac4aff1be..4e623bc5c 100644 --- a/node/test/toolrunnertests.ts +++ b/node/test/toolrunnertests.ts @@ -1229,7 +1229,15 @@ describe('Toolrunner Tests', function () { assert.equal((node as any).args.toString(), '--path,/bin/working folder1', 'should be --path /bin/working folder1'); done(); }) - + it('handles escaped quotes', function (done) { + this.timeout(10000); + var node = tl.tool(tl.which('node', true)); + node.line('-TEST="escaped\\\"quotes" -x'); + node.arg('-y'); + assert.equal((node as any).args.length, 3, 'should have 3 args'); + assert.equal((node as any).args.toString(), '-TEST=escaped"quotes,-x,-y', 'should be -TEST=escaped"quotes,-x,-y'); + done(); + }) if (process.platform != 'win32') { it('exec prints [command] (OSX/Linux)', function (done) { this.timeout(10000); diff --git a/node/toolrunner.ts b/node/toolrunner.ts index 8f2e569ad..843dfe2b7 100644 --- a/node/toolrunner.ts +++ b/node/toolrunner.ts @@ -96,10 +96,13 @@ export class ToolRunner extends events.EventEmitter { var append = function (c: string) { // we only escape double quotes. - if (escaped && c !== '"') { - arg += '\\'; + if (escaped) { + if (c !== '"') { + arg += '\\'; + } else { + arg.slice(0, -1); + } } - arg += c; escaped = false; }