From a6304fb2a6346ed49ba23b52c10277091f01938c Mon Sep 17 00:00:00 2001 From: Vincent Latombe Date: Thu, 21 Jan 2021 08:52:42 +0100 Subject: [PATCH] Revert "[JENKINS-62502] `ContainerExecDecorator` should escape double quotes" --- .../kubernetes/pipeline/ContainerExecDecorator.java | 3 +-- .../pipeline/ContainerExecDecoratorTest.java | 12 +----------- 2 files changed, 2 insertions(+), 13 deletions(-) diff --git a/src/main/java/org/csanchez/jenkins/plugins/kubernetes/pipeline/ContainerExecDecorator.java b/src/main/java/org/csanchez/jenkins/plugins/kubernetes/pipeline/ContainerExecDecorator.java index 52823b53d2..f060bd8d60 100755 --- a/src/main/java/org/csanchez/jenkins/plugins/kubernetes/pipeline/ContainerExecDecorator.java +++ b/src/main/java/org/csanchez/jenkins/plugins/kubernetes/pipeline/ContainerExecDecorator.java @@ -654,8 +654,7 @@ static String[] getCommands(Launcher.ProcStarter starter, String containerWorkin // BourneShellScript.launchWithCookie escapes $ as $$, we convert it to \$ for (String cmd : starter.cmds()) { - String fixedCommand = cmd.replaceAll("\\$\\$", Matcher.quoteReplacement("\\$")) - .replaceAll("\\\"", Matcher.quoteReplacement("\\\"")); + String fixedCommand = cmd.replaceAll("\\$\\$", "\\\\\\$"); String oldRemoteDir = null; FilePath oldRemoteDirFilepath = starter.pwd(); diff --git a/src/test/java/org/csanchez/jenkins/plugins/kubernetes/pipeline/ContainerExecDecoratorTest.java b/src/test/java/org/csanchez/jenkins/plugins/kubernetes/pipeline/ContainerExecDecoratorTest.java index b99b5f666c..438482c50d 100644 --- a/src/test/java/org/csanchez/jenkins/plugins/kubernetes/pipeline/ContainerExecDecoratorTest.java +++ b/src/test/java/org/csanchez/jenkins/plugins/kubernetes/pipeline/ContainerExecDecoratorTest.java @@ -270,17 +270,7 @@ public void testCommandExecutionWithEscaping() throws Exception { } @Test - @Issue("JENKINS-62502") - public void testCommandExecutionEscapingDoubleQuotes() throws Exception { - ProcReturn r = execCommand(false, false, "sh", "-c", "cd /tmp; false; echo \"result is 1\" > test; cat /tmp/test"); - assertTrue("Output should contain result: " + r.output, - Pattern.compile("^(result is 1)$", Pattern.MULTILINE).matcher(r.output).find()); - assertEquals(0, r.exitCode); - assertFalse(r.proc.isAlive()); - } - - @Test - public void testCommandExecutionOutput() throws Exception { + public void testCommandExecutionOutput() throws Exception { String testString = "Should appear once"; // Check output with quiet=false