Skip to content

Commit

Permalink
iss-4535
Browse files Browse the repository at this point in the history
Changed to be much shorter as pointed out, manual still passes tests.
New test added
Changelog moved.

fabric8io#4535
  • Loading branch information
BrianDevC committed Oct 27, 2022
1 parent 8f5c7aa commit 888b291
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Expand Up @@ -3,6 +3,7 @@
### 6.3-SNAPSHOT

#### Bugs
* Fix #4535: The shell command string will now have single quotes sanitized

#### Improvements

Expand All @@ -15,7 +16,6 @@
### 6.2.0 (2022-10-20)

#### Bugs
* Fix #4535: The shell command string will now have single quotes sanitized
* Fix #3733: The authentication command from the .kube/config won't be discarded if no arguments are specified
* Fix #4312: fix timestamp can't be deserialized for IstioCondition
* Fix #4369: Informers will retry with a backoff on list/watch failure as they did in 5.12 and prior.
Expand Down
Expand Up @@ -591,7 +591,7 @@ public BytesLimitTerminateTimeTailPrettyLoggable usingTimestamps() {
}

public static String shellQuote(String value) {
return "'" + value.replace("'", "\'\"\'\"\'") + "'";
return "'" + value.replace("'", "'\\''") + "'";
}

@Override
Expand Down
Expand Up @@ -186,7 +186,7 @@ void createExecCommandForUpload_withSingleQuoteInPath()
String result = PodUpload.createExecCommandForUpload("/tmp/fo'o/cp.log");

// Then
assertThat(result, equalTo("mkdir -p '/tmp/fo\'\"\'\"\'o' && base64 -d - > '/tmp/fo\'\"\'\"\'o/cp.log'"));
assertThat(result, equalTo("mkdir -p '/tmp/fo\'\\'\'o' && base64 -d - > '/tmp/fo\'\\'\'o/cp.log'"));
}

@Test
Expand All @@ -196,7 +196,7 @@ void createExecCommandForUpload_withMultipleSingleQuotesInPath()
String result = PodUpload.createExecCommandForUpload("/tmp/f'o'o/c'p.log");

// Then
assertThat(result, equalTo("mkdir -p '/tmp/f\'\"\'\"\'o\'\"\'\"\'o' && base64 -d - > '/tmp/f\'\"\'\"\'o\'\"\'\"\'o/c\'\"\'\"\'p.log'"));
assertThat(result, equalTo("mkdir -p '/tmp/f\'\\'\'o\'\\'\'o' && base64 -d - > '/tmp/f\'\\'\'o\'\\'\'o/c\'\\'\'p.log'"));
}

void uploadFileAndVerify(PodUploadTester<Boolean> fileUploadMethodToTest) throws IOException, InterruptedException {
Expand Down
Expand Up @@ -274,6 +274,7 @@ void uploadFile() throws IOException {

assertUploaded("pod-standard", tmpFile, "/tmp/toBeUploaded");
assertUploaded("pod-standard", tmpFile, "/tmp/001_special_!@#\\$^&(.mp4");
assertUploaded("pod-standard", tmpFile, "/tmp/002'special");
}

private void assertUploaded(String podName, final Path tmpFile, String filename) throws IOException {
Expand Down

0 comments on commit 888b291

Please sign in to comment.