Skip to content

Commit

Permalink
[UNDERTOW-2383] do not canonicalize query string in sendRedirect loca…
Browse files Browse the repository at this point in the history
…tion
  • Loading branch information
aogburn committed Apr 26, 2024
1 parent a41521a commit 118ce73
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,14 @@ public void sendRedirect(final String location) throws IOException {
} else {
current = "";
}
realPath = CanonicalPathUtils.canonicalize(servletContext.getContextPath() + current + location);
String precanonLocation = location;
String query = "";
int firstQuestionMark = location.indexOf("?");
if (firstQuestionMark >= 0) {
precanonLocation = location.substring(0, firstQuestionMark);
query = location.substring(firstQuestionMark);
}
realPath = CanonicalPathUtils.canonicalize(servletContext.getContextPath() + current + precanonLocation) + query;
}
String loc = exchange.getRequestScheme() + "://" + exchange.getHostAndPort() + realPath;
exchange.getResponseHeaders().put(Headers.LOCATION, loc);
Expand Down

0 comments on commit 118ce73

Please sign in to comment.