Skip to content

Commit 0d4c619

Browse files
committed
Include continue in query string
Closes gh-12665
1 parent 4a8961b commit 0d4c619

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.
@@ -226,7 +226,8 @@ public boolean doesRequestMatch(HttpServletRequest request, PortResolver portRes
226226
if (!propertyEquals(this.pathInfo, request.getPathInfo())) {
227227
return false;
228228
}
229-
if (!propertyEquals(this.queryString, request.getQueryString())) {
229+
if (!propertyEquals(createQueryString(this.queryString, this.matchingRequestParameterName),
230+
request.getQueryString())) {
230231
return false;
231232
}
232233
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.
@@ -115,6 +115,23 @@ public void getMatchingRequestWhenMatchingRequestParameterNameSetAndParameterExi
115115
cache.setMatchingRequestParameterName("success");
116116
cache.saveRequest(request, new MockHttpServletResponse());
117117
MockHttpServletRequest requestToMatch = new MockHttpServletRequest();
118+
requestToMatch.setQueryString("success"); // gh-12665
119+
requestToMatch.setParameter("success", "");
120+
requestToMatch.setSession(request.getSession());
121+
HttpServletRequest matchingRequest = cache.getMatchingRequest(requestToMatch, new MockHttpServletResponse());
122+
assertThat(matchingRequest).isNotNull();
123+
}
124+
125+
// gh-12665
126+
@Test
127+
public void getMatchingRequestWhenMatchingRequestParameterNameSetAndParameterExistAndQueryThenLookedUp() {
128+
MockHttpServletRequest request = new MockHttpServletRequest();
129+
request.setQueryString("param=true");
130+
HttpSessionRequestCache cache = new HttpSessionRequestCache();
131+
cache.setMatchingRequestParameterName("success");
132+
cache.saveRequest(request, new MockHttpServletResponse());
133+
MockHttpServletRequest requestToMatch = new MockHttpServletRequest();
134+
requestToMatch.setQueryString("param=true&success");
118135
requestToMatch.setParameter("success", "");
119136
requestToMatch.setSession(request.getSession());
120137
HttpServletRequest matchingRequest = cache.getMatchingRequest(requestToMatch, new MockHttpServletResponse());

0 commit comments

Comments
 (0)