javax.ws.rs.core.UriBuilder
未正确转发}
:
import javax.ws.rs.core.UriBuilder;
public void test() {
final UriBuilder builder = UriBuilder.fromUri("http://host");
builder.path("dir}one");
l.info(builder.toString());
}
输出http://host/dir}one
,保留}
未转义。
而org.apache.http.client.utils.URIBuilder
:
org.apache.http.client.utils.URIBuilder;
public void testApache() {
final URIBuilder builder = new URIBuilder(URI.create("http://host"));
builder.setPath("dir}one");
l.info(builder.toString());
}
输出http://hostdir%7Done
,按预期使用}
转发%7D
。
这是javax.ws.rs.core.UriBuilder
中的错误吗?
答案 0 :(得分:1)
According to RFC 3986 the character } is not a reserved character and therefore it need not be escaped. It can be escaped with %7D, but that is not necessary.
So both UriBuilder
implementations behave correctly.