Skip to content

prefixPath filter double encodes URLs #3769

Closed
@SebHeuze

Description

@SebHeuze

Describe the bug
In last version of Spring Gateway MVC, prefixPath filter does not support Encoded url like "/url with/space"
The path is transformed to "/url%2520with/space" instead of "/url%20with/space"
The filter should use getPath instead of getRawPath

Similar to #3482

Sample
Adding this test in BeforeFilterFunctionsTests reproduce the issue

@Test
void prefixEncodedPath() {
	MockHttpServletRequest servletRequest = MockMvcRequestBuilders
			.get("http://localhost/get/é").buildRequest(null);
	ServerRequest request = ServerRequest.create(servletRequest,
			Collections.emptyList());
	ServerRequest modified = BeforeFilterFunctions.prefixPath("/pre fix")
			.apply(request);
	assertThat(modified.uri().getRawPath()).isEqualTo("/pre%20fix/get/%C3%A9");
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Status

    No status

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions