Hi there!
Thanks for taking a look at this issue. Please let me know if you require more information.
Let's discuss!
Describe the bug
HttpSessionRequestCache#getMatchingRequest relies on org.springframework.web.util.UriComponentsBuilder#fromUriString(String) to be able to handle decoded % characters.
To Reproduce
The org.springframework.web.util.UriComponentsBuilder#fromUriString(String) cannot handle a % followed by characters that result in false %-encoding.
@Test
void unencodedPercent(){
assertThatRuntimeException().isThrownBy(() -> UriComponentsBuilder.fromUriString("/30 % off"));
}
This leads to a org.springframework.web.util.InvalidUrlException: Bad path when such a request gets to
|
|| !UriComponentsBuilder.fromUriString(UrlUtils.buildRequestUrl(request)) |
An encoded request
https://example.com/myapp/discounts/30%20%25%20off is returned decoded by
|
* @return the decoded URL, excluding any server name, context path or servlet path |
|
* |
|
*/ |
|
public static String buildRequestUrl(HttpServletRequest r) { |
The
UriComponentsBuilder cannot handle this decoded
%
Expected behavior
My request does not result in an InvalidUrlException.
Hi there!
Thanks for taking a look at this issue. Please let me know if you require more information.
Let's discuss!
Describe the bug
HttpSessionRequestCache#getMatchingRequestrelies onorg.springframework.web.util.UriComponentsBuilder#fromUriString(String)to be able to handle decoded%characters.To Reproduce
The
org.springframework.web.util.UriComponentsBuilder#fromUriString(String)cannot handle a%followed by characters that result in false %-encoding.This leads to a
org.springframework.web.util.InvalidUrlException: Bad pathwhen such a request gets tospring-security/web/src/main/java/org/springframework/security/web/savedrequest/HttpSessionRequestCache.java
Line 107 in ec3cc66
An encoded request
https://example.com/myapp/discounts/30%20%25%20offis returned decoded byspring-security/web/src/main/java/org/springframework/security/web/util/UrlUtils.java
Lines 91 to 94 in ec3cc66
The
UriComponentsBuildercannot handle this decoded%Expected behavior
My request does not result in an
InvalidUrlException.