You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Related to #337 when a rel contains a mandatory param that needs to be escaped, it will be escaped twice.
In the following example, the rel to follow is /springagram/item/{itemId} where itemId is '123#456'
The final url will be resolved as /springagram/item/123%2523456 instead of /springagram/item/123%23456
The problem is inside org.springframework.hateoas.UriTemplate#expand(java.util.Map<java.lang.String,? extends java.lang.Object>)
When creating a new org.springframework.web.util.UriTemplate, the baseUri is escaped a first time (# is escaped as %23).
Then, when executing builder.build().toUri() the whole url is escaped a second time (hence %23 is escaped as %2523).
The thing is that is works well if you only have optional param inside your rel but as soon as you have one mandatiry param that needs to be escaped, then it will be escaped twice.
The text was updated successfully, but these errors were encountered:
ydecoux
added a commit
to ydecoux/spring-hateoas
that referenced
this issue
Sep 28, 2016
Also, due to the same code portion, non-ascii optional parameters don't get encoded at all. E.g. to use your itemId as optional param:
/springagram/item/{?itemId}
final Link link = new Link("/springagram/item/{?itemId}");
System.out.println(link.expand(Collections.singletonMap("itemId", "MØ")).getHref());
prints /springagram/item/?itemId=MØ instead of the expected /springagram/item/?itemId=M%C3%98.
As a reminder, non-ascii characters in URLs must be encoded, this doesn't necessarily apply to URIs.
@ydecoux I know this issue is more than two years old, but could you please create a PR, maybe the project leads can have a quick look into it and make your fix part of the next release. Fingers crossed.
Related to #337 when a rel contains a mandatory param that needs to be escaped, it will be escaped twice.
In the following example, the rel to follow is
/springagram/item/{itemId}
where itemId is '123#456'The final url will be resolved as
/springagram/item/123%2523456
instead of/springagram/item/123%23456
The problem is inside
org.springframework.hateoas.UriTemplate#expand(java.util.Map<java.lang.String,? extends java.lang.Object>)
When creating a new org.springframework.web.util.UriTemplate, the baseUri is escaped a first time (# is escaped as %23).
Then, when executing
builder.build().toUri()
the whole url is escaped a second time (hence %23 is escaped as %2523).The thing is that is works well if you only have optional param inside your rel but as soon as you have one mandatiry param that needs to be escaped, then it will be escaped twice.
The text was updated successfully, but these errors were encountered: