mirror of
https://github.com/spring-projects/spring-boot.git
synced 2024-08-29 03:06:45 +08:00
Sanitize URIs with non-alpha characters in their schemes
See gh-27482
This commit is contained in:
parent
cff1827e27
commit
bafa9c4784
@ -50,7 +50,7 @@ public class Sanitizer {
|
||||
private static final Set<String> URI_USERINFO_KEYS = new LinkedHashSet<>(
|
||||
Arrays.asList("uri", "uris", "address", "addresses"));
|
||||
|
||||
private static final Pattern URI_USERINFO_PATTERN = Pattern.compile("\\[?[A-Za-z]+://.+:(.*)@.+$");
|
||||
private static final Pattern URI_USERINFO_PATTERN = Pattern.compile("^[A-Za-z][A-Za-z0-9\\+\\.\\-]+://.+:(.*)@.+$");
|
||||
|
||||
private Pattern[] keysToSanitize;
|
||||
|
||||
|
@ -52,8 +52,8 @@ class SanitizerTests {
|
||||
@MethodSource("matchingUriUserInfoKeys")
|
||||
void uriWithSingleValueWithPasswordShouldBeSanitized(String key) {
|
||||
Sanitizer sanitizer = new Sanitizer();
|
||||
assertThat(sanitizer.sanitize(key, "http://user:password@localhost:8080"))
|
||||
.isEqualTo("http://user:******@localhost:8080");
|
||||
assertThat(sanitizer.sanitize(key, "view-source://user:password@localhost:8080"))
|
||||
.isEqualTo("view-source://user:******@localhost:8080");
|
||||
}
|
||||
|
||||
@ParameterizedTest(name = "key = {0}")
|
||||
|
Loading…
Reference in New Issue
Block a user