Skip to content

Commit bafa9c4

Browse files
billytowilkinsona
authored andcommitted
Sanitize URIs with non-alpha characters in their schemes
See gh-27482
1 parent cff1827 commit bafa9c4

File tree

2 files changed

+3
-3
lines changed
  • spring-boot-project/spring-boot-actuator/src

2 files changed

+3
-3
lines changed

spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/Sanitizer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public class Sanitizer {
5050
private static final Set<String> URI_USERINFO_KEYS = new LinkedHashSet<>(
5151
Arrays.asList("uri", "uris", "address", "addresses"));
5252

53-
private static final Pattern URI_USERINFO_PATTERN = Pattern.compile("\\[?[A-Za-z]+://.+:(.*)@.+$");
53+
private static final Pattern URI_USERINFO_PATTERN = Pattern.compile("^[A-Za-z][A-Za-z0-9\\+\\.\\-]+://.+:(.*)@.+$");
5454

5555
private Pattern[] keysToSanitize;
5656

spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/SanitizerTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@ void defaultNonUriKeys() {
5252
@MethodSource("matchingUriUserInfoKeys")
5353
void uriWithSingleValueWithPasswordShouldBeSanitized(String key) {
5454
Sanitizer sanitizer = new Sanitizer();
55-
assertThat(sanitizer.sanitize(key, "http://user:password@localhost:8080"))
56-
.isEqualTo("http://user:******@localhost:8080");
55+
assertThat(sanitizer.sanitize(key, "view-source://user:password@localhost:8080"))
56+
.isEqualTo("view-source://user:******@localhost:8080");
5757
}
5858

5959
@ParameterizedTest(name = "key = {0}")

0 commit comments

Comments
 (0)