0

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吗?

4

1 回答 1

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.

于 2017-07-17T15:26:43.747 回答