Skip to content

Commit 9520eb9

Browse files
quaffsnicoll
authored andcommitted
Do not use String#replaceAll() with a non-regex pattern
See gh-49816 Signed-off-by: Yanming Zhou <zhouyanming@gmail.com>
1 parent 9a74fd5 commit 9520eb9

6 files changed

Lines changed: 6 additions & 6 deletions

File tree

spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/main/java/org/springframework/boot/buildpack/platform/docker/ssl/PemCertificateParser.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ private static void readCertificates(String text, CertificateFactory factory, Co
9292
}
9393

9494
private static byte[] decodeBase64(String content) {
95-
byte[] bytes = content.replaceAll("\r", "").replaceAll("\n", "").getBytes();
95+
byte[] bytes = content.replace("\r", "").replace("\n", "").getBytes();
9696
return Base64.getDecoder().decode(bytes);
9797
}
9898

spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/main/java/org/springframework/boot/buildpack/platform/docker/ssl/PemPrivateKeyParser.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ PrivateKey parse(String text, String password) {
240240
}
241241

242242
private static byte[] decodeBase64(String content) {
243-
byte[] contentBytes = content.replaceAll("\r", "").replaceAll("\n", "").getBytes();
243+
byte[] contentBytes = content.replace("\r", "").replace("\n", "").getBytes();
244244
return Base64.getDecoder().decode(contentBytes);
245245
}
246246

spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/test/java/org/springframework/boot/buildpack/platform/build/LifecycleTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -482,7 +482,7 @@ private Answer<ContainerReference> answerWithGeneratedContainerId() {
482482
return (invocation) -> {
483483
ContainerConfig config = invocation.getArgument(0, ContainerConfig.class);
484484
ArrayNode command = getCommand(config);
485-
String name = command.get(0).asText().substring(1).replaceAll("/", "-");
485+
String name = command.get(0).asText().substring(1).replace('/', '-');
486486
this.configs.put(name, config);
487487
if (invocation.getArguments().length > 2) {
488488
this.content.put(name, invocation.getArgument(2, ContainerContent.class));

spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/test/java/org/springframework/boot/buildpack/platform/docker/ssl/PemFileWriter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ public PemFileWriter() throws IOException {
181181
Path writeFile(String name, String... contents) throws IOException {
182182
Path path = Paths.get(this.tempDir.toString(), name);
183183
for (String content : contents) {
184-
Files.write(path, content.replaceAll(EXAMPLE_SECRET_QUALIFIER, "").getBytes(), StandardOpenOption.CREATE,
184+
Files.write(path, content.replace(EXAMPLE_SECRET_QUALIFIER, "").getBytes(), StandardOpenOption.CREATE,
185185
StandardOpenOption.APPEND);
186186
}
187187
return path;

spring-boot-project/spring-boot/src/main/java/org/springframework/boot/ssl/pem/PemCertificateParser.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ private static void readCertificates(String text, CertificateFactory factory, Co
9292
}
9393

9494
private static byte[] decodeBase64(String content) {
95-
byte[] bytes = content.replaceAll("\r", "").replaceAll("\n", "").getBytes();
95+
byte[] bytes = content.replace("\r", "").replace("\n", "").getBytes();
9696
return Base64.getDecoder().decode(bytes);
9797
}
9898

spring-boot-project/spring-boot/src/main/java/org/springframework/boot/ssl/pem/PemPrivateKeyParser.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ PrivateKey parse(String text, String password) {
240240
}
241241

242242
private static byte[] decodeBase64(String content) {
243-
byte[] contentBytes = content.replaceAll("\r", "").replaceAll("\n", "").getBytes();
243+
byte[] contentBytes = content.replace("\r", "").replace("\n", "").getBytes();
244244
return Base64.getDecoder().decode(contentBytes);
245245
}
246246

0 commit comments

Comments
 (0)