Skip to content

Commit

Permalink
#1722 - Fix double encoding of request parameters in LinkBuilderSuppo…
Browse files Browse the repository at this point in the history
…rt.toUri(…).

We unfortunately cannot use UriComponentsBuilder in a way that we can populate it with encoded parameters *and* expand encoded path variable values. We currently use ….buildAndExpand(…) which considers the values provided unencoded but we never actually call ….toUri() on the resulting UriComponents instance.

We unfortunately cannot fix the problem at its root, as the only alternative would be to call ….build(true) indicating values already encoded but that stumbles above the template variables still present in the original template.

The only workaround right now is never calling UriComponents.toUri() but ….toUriString() as that doesn't apply the pending encoding that's not actually needed as we start with fully encoded values in the first place.
  • Loading branch information
odrotbohm committed May 16, 2022
1 parent 57317d0 commit 19c2480
Showing 1 changed file with 1 addition and 1 deletion.
Expand Up @@ -119,7 +119,7 @@ protected T slash(UriComponents components, boolean encoded) {
* @see org.springframework.hateoas.LinkBuilder#toUri()
*/
public URI toUri() {
return components.toUri().normalize();
return URI.create(components.toUriString());
}

public T addAffordances(Collection<Affordance> affordances) {
Expand Down

0 comments on commit 19c2480

Please sign in to comment.