spring-projects / spring-projects/spring-hateoas

1.5.x no longer % encodes @RequestParam name - produces illegal URI

Open
#2,083 1 comment 0 reactions 1 assignee View on GitHub

@odrotbohm is already working on this.

Since Jan 11, 2024.

process: in progress
Dominant language
Java
Stars
1.1k
Forks
476
PR merge metrics
No merged PRs in 30d

Description

When (finally) upgrading to 1.5, it appears there is a notable change in the encoding of request parameters where we use linkTo(methodOn(..)).

With 1.3, @RequestParam("with space") appeared as ?with%20space=value which matches the RFC var name spec.

With 1.5, we get ?with space=value which correctly blows up with an illegal URI query character.

There is no documentation or examples that I've found that assert whether Spring HATEOAS supports params with spaces.

For us, this is a regression, but it may be have been an undocumented assumption?

Within the Spring HATEOAS codebase, this change in WebMvcLinkBuilderUnitTest shows the URL containing a space:

@RequestMapping("/foo")
HttpEntity<Void> methodWithRequestParam(@RequestParam("the id") String id) {
	return null;
}

and an update to WebMvcLinkBuilderUnitTest.encodesRequestParameterWithSpecialValue() results in this fail:

Expecting actual:
  "http://localhost/something/foo?the id=Spring%23%0A"
to end with:
  "/something/foo?the%20id=Spring%23%0A"

Note: Tweaking test also fails in the 1.3.x branch, so while it's elsewhere we've got URL encoding differing between 1.3 and 1.5, the above changes demonstrate the incorrect encoding.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.