From 3b120350621a4c00c4f0f8ee74b573058d6d9c01 Mon Sep 17 00:00:00 2001 From: Christoph Bergmeister Date: Sat, 26 Jan 2019 19:07:38 +0000 Subject: [PATCH 1/2] Handle describe block strings with single quotes inside it. --- src/features/PesterTests.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/features/PesterTests.ts b/src/features/PesterTests.ts index 75bb17698b..ccd6c577f0 100644 --- a/src/features/PesterTests.ts +++ b/src/features/PesterTests.ts @@ -72,6 +72,10 @@ export class PesterTestsFeature implements IFeature { if (describeBlockName) { launchConfig.args.push("-TestName"); + // Escape single quotes inside double quotes + if (describeBlockName.includes("'")) { + describeBlockName = describeBlockName.replace("'", "''"); + } launchConfig.args.push(`'${describeBlockName}'`); } From 2a2716880645e807d8b1934f6bbaf4b88cae9cfd Mon Sep 17 00:00:00 2001 From: Christoph Bergmeister Date: Tue, 29 Jan 2019 21:23:05 +0000 Subject: [PATCH 2/2] fix replace call to handle expression with more than one single quote as well --- src/features/PesterTests.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/features/PesterTests.ts b/src/features/PesterTests.ts index ccd6c577f0..34c3a5cc57 100644 --- a/src/features/PesterTests.ts +++ b/src/features/PesterTests.ts @@ -72,9 +72,9 @@ export class PesterTestsFeature implements IFeature { if (describeBlockName) { launchConfig.args.push("-TestName"); - // Escape single quotes inside double quotes + // Escape single quotes inside double quotes by doubling them up if (describeBlockName.includes("'")) { - describeBlockName = describeBlockName.replace("'", "''"); + describeBlockName = describeBlockName.replace(/'/g, "''"); } launchConfig.args.push(`'${describeBlockName}'`); }