spring-projects / spring-projects/spring-hateoas

ControllerLinkBuilder.linkTo dont encode slash in parameters

Open
#569 4 comments 6 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

I have a code like this

ControllerLinkBuilder.linkTo(ControllerLinkBuilder.methodOn(MyClass.class)
                               .MyMethod(param1, param2, param3));

when my param3 is equal to "aa/bb" i want to have na encoded url who will contain "aa%2Fbb" but the slash is not encoded and i get a value containing "aa/bb"

and when i try to encode it and give the methode and encoded parameter like this

String encodedParam3= java.net.URLEncoder.encode(param3, "UTF-8");
ControllerLinkBuilder.linkTo(ControllerLinkBuilder.methodOn(MyClass.class)
                               .MyMethod(param1, param2, encodedParam3));

ControllerLinkBuilder.linkTo will encode the "%" in my encodedParam3 to "%25" and i will get a value containing "aa%252Fbb"

I am using spring hateoas 0.23.0-RELEASE

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.

Research direction

Start by reproducing the issue through ControllerLinkBuilder.linkTo with a parameter value of "aa/bb", then compare the result with the pre-encoded "%2F" case. Trace the ControllerLinkBuilder encoding path and verify that the slash is encoded once without double-encoding the percent sign; done means the generated URL contains "aa%2Fbb".

Written by the indexing model from the issue text.

Assessment

Tech stack
java, spring
Domain
api
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.