-
Notifications
You must be signed in to change notification settings - Fork 38.5k
UriTemplate unconditionally percent-encodes literal part #24094
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
DefaultUriBuilderFactory factory = new DefaultUriBuilderFactory();
factory.setEncodingMode(EncodingMode.VALUES_ONLY);
URI url = factory.uriString("https://example.org/foo%20and%20bar/{baz}").build("xyzzy"); Also see the reference on URI Links. |
Closing but feel free to comment. |
Also update Javadoc of UriTemplate to point to UriComponentsBuilder and UriBuilderFactory as more flexible options. See gh-24094
Many thanks @rstoyanchev I agree this is the better approach. Actually I've been using |
Affects: 5.2.1 and earlier
When using
UriTemplate
with a properly percent-encoded literal part, the percent sign gets encoded a second time. For exampleyields
https://example.org/foo%2520and%2520bar/xyzzy
rather than the expectedhttps://example.org/foo%20and%20bar/xyzzy
.UriTemplate
's constructor usesUriComponentsBuilder.build()
without any arguments. One option could be to provide a second constructor with a booleanencoded
argument mirroring the one-arg version ofUriComponentsBuilder.build()
. If this sounds like a useful addition I can create a small PR.The text was updated successfully, but these errors were encountered: