Skip to content

Commit e7d6596

Browse files
committed
Merge branch '5.8.x' into 6.0.x
Closes gh-12671
2 parents 2b36499 + 0d4c619 commit e7d6596

File tree

2 files changed

+21
-3
lines changed

2 files changed

+21
-3
lines changed

web/src/main/java/org/springframework/security/web/savedrequest/DefaultSavedRequest.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2022 the original author or authors.
2+
* Copyright 2002-2023 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -225,7 +225,8 @@ public boolean doesRequestMatch(HttpServletRequest request, PortResolver portRes
225225
if (!propertyEquals(this.pathInfo, request.getPathInfo())) {
226226
return false;
227227
}
228-
if (!propertyEquals(this.queryString, request.getQueryString())) {
228+
if (!propertyEquals(createQueryString(this.queryString, this.matchingRequestParameterName),
229+
request.getQueryString())) {
229230
return false;
230231
}
231232
if (!propertyEquals(this.requestURI, request.getRequestURI())) {

web/src/test/java/org/springframework/security/web/savedrequest/HttpSessionRequestCacheTests.java

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2016 the original author or authors.
2+
* Copyright 2002-2023 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -114,6 +114,23 @@ public void getMatchingRequestWhenMatchingRequestParameterNameSetAndParameterExi
114114
cache.setMatchingRequestParameterName("success");
115115
cache.saveRequest(request, new MockHttpServletResponse());
116116
MockHttpServletRequest requestToMatch = new MockHttpServletRequest();
117+
requestToMatch.setQueryString("success"); // gh-12665
118+
requestToMatch.setParameter("success", "");
119+
requestToMatch.setSession(request.getSession());
120+
HttpServletRequest matchingRequest = cache.getMatchingRequest(requestToMatch, new MockHttpServletResponse());
121+
assertThat(matchingRequest).isNotNull();
122+
}
123+
124+
// gh-12665
125+
@Test
126+
public void getMatchingRequestWhenMatchingRequestParameterNameSetAndParameterExistAndQueryThenLookedUp() {
127+
MockHttpServletRequest request = new MockHttpServletRequest();
128+
request.setQueryString("param=true");
129+
HttpSessionRequestCache cache = new HttpSessionRequestCache();
130+
cache.setMatchingRequestParameterName("success");
131+
cache.saveRequest(request, new MockHttpServletResponse());
132+
MockHttpServletRequest requestToMatch = new MockHttpServletRequest();
133+
requestToMatch.setQueryString("param=true&success");
117134
requestToMatch.setParameter("success", "");
118135
requestToMatch.setSession(request.getSession());
119136
HttpServletRequest matchingRequest = cache.getMatchingRequest(requestToMatch, new MockHttpServletResponse());

0 commit comments

Comments
 (0)