Skip to content

Multiple slash sanitisation should be optional in UriComponentsBuilder #34076

@dpozinen

Description

@dpozinen

The primary reason for this issue is spring-cloud/spring-cloud-gateway#2795 which under the hood uses UriComponentsBuilder. See this comment specifically: spring-cloud/spring-cloud-gateway#2795 (comment)

In the context of #14904 and #17006 there have been changes made to sanitise multiple consecutive slashes and replace them via a single slash:

private static String getSanitizedPath(final StringBuilder 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();
}
return path.toString();

Technically, there is no restriction on multiple consecutive slashes - those are valid urls, so I think that adding the option of preserving those in UriComponentsBuilder would be a good thing, and would solve the mentioned gateway issue.

What do you think?

Metadata

Metadata

Assignees

No one assigned

    Labels

    in: webIssues in web modules (web, webmvc, webflux, websocket)status: declinedA suggestion or change that we don't feel we should currently apply

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions