Merge branch '5.3.x' into main

This commit is contained in:
Rossen Stoyanchev
2021-11-09 10:23:14 +00:00
3 changed files with 23 additions and 14 deletions

View File

@@ -404,16 +404,18 @@ public class UrlPathHelper {
* </ul>
*/
private static String getSanitizedPath(final String path) {
int index = path.indexOf("//");
if (index >= 0) {
StringBuilder sanitized = new StringBuilder(path);
while (index != -1) {
sanitized.deleteCharAt(index);
index = sanitized.indexOf("//", index);
}
return sanitized.toString();
int start = path.indexOf("//");
if (start == -1) {
return path;
}
return path;
char[] content = path.toCharArray();
int slowIndex = start;
for (int fastIndex = start + 1; fastIndex < content.length; fastIndex++) {
if (content[fastIndex] != '/' || content[slowIndex] != '/') {
content[++slowIndex] = content[fastIndex];
}
}
return new String(content, 0, slowIndex + 1);
}
/**
@@ -531,7 +533,7 @@ public class UrlPathHelper {
*/
public String getOriginatingQueryString(HttpServletRequest request) {
if ((request.getAttribute(WebUtils.FORWARD_REQUEST_URI_ATTRIBUTE) != null) ||
(request.getAttribute(WebUtils.ERROR_REQUEST_URI_ATTRIBUTE) != null)) {
(request.getAttribute(WebUtils.ERROR_REQUEST_URI_ATTRIBUTE) != null)) {
return (String) request.getAttribute(WebUtils.FORWARD_QUERY_STRING_ATTRIBUTE);
}
else {