Skip to content

Allowing reserved characters in a path variables makes '+' decode as a space #8090

Open
@Iman78

Description

@Iman78

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

  1. Any project with an http server.
  2. Add an endpoint that has a path variable allowing reserved characters: @Get("{+variable}")
  3. Send a request to said endpoint with a value containing the plus sign.
  4. 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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions