Allowing reserved characters in a path variables makes '+' decode as a space
Expected Behavior
To support '+' in the path portion of the url, I'm using https://www.rfc-editor.org/rfc/rfc6570#section-3.2.3 to allow reserved characters like so:
@Get("{+variable}")
public HttpResponse<Object> method(@PathVariable("variable") String variable) {
...
}
From this test I understand that f I call my GET endpoint with /tes+t, I should expect the value of variable to be tes+t.
Actual Behaviour
Instead I get tes t. The plus sign is decoded as a space, which seems to be due to the use of java.net.URLDecoder in DefaultUriRouteMatch.
If you think this behavior should remain, then it'd be very helpful to have a configuration to opt-out of it.
Steps To Reproduce
- Any project with an http server.
- Add an endpoint that has a path variable allowing reserved characters:
@Get("{+variable}") - Send a request to said endpoint with a value containing the plus sign.
- Inspect the value of the variable inside to annotated method, it should have a space instead of the plus sign.
Environment Information
OS: MacOS Catalina JDK 11
Example Application
No response
Version
3.6.0
Can you please confirm that this is still an issue in the latest version of Micronaut?
Hi,
Not sure if it is completely related with the current issue but in micronaut 4.9.x, the following is happening.
With a client like below:
@Client
public interface MyClient {
@Get("/test/{rest}")
HttpResponse<@NotNull String> test(@PathVariable("rest") @NotNull String rest);
}
A call like:
myClient.test("this/will/be/encoded")
Leads to:
GET /test/this%2Fwill%2Fbe%2Fencoded
While the expected is:
GET /test/this/will/be/encoded
It would be nice if not encoding could be passed on to the client.
Thanks!