[ 
https://issues.apache.org/jira/browse/HTTPCORE-787?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18034722#comment-18034722
 ] 

Oleg Kalnichevski commented on HTTPCORE-787:
--------------------------------------------

> I hope you will consider clarifying the method’s doc. The 
> [doc|https://docs.oracle.com/en/java/javase/21/docs/api/java.base/java/net/URI.html#getPath()]
>  on {{java.net.URI.getPath()}} is much clearer, for example:

[~jaredjacobs] Thank you for your interest in HttpComponents. We are aware our 
documentation is quite poor. So, please do consider to submit javadoc 
improvements you are proposing as a pull request at GitHub.

> Regarding your disdain for “Those people who need silliness like '/' 
> character in their path segments”, please consider the fact that many people 
> use Apache HTTP libraries as _clients_ of APIs they didn’t design, so they 
> have no say in what characters occur in path segments.

Regarding my disdain, please do note that HttpComponents are being used by many 
different people with different, often conflicting expectations and 
requirements. Instead of trying to get `URIBuilder` adjusted to your 
expectations please consider reporting the problem to those people who designed 
those APIs and let them know what they are doing is quite silly.

Oleg

 

> URIBuilder.getPath() should escape each segment
> -----------------------------------------------
>
>                 Key: HTTPCORE-787
>                 URL: https://issues.apache.org/jira/browse/HTTPCORE-787
>             Project: HttpComponents HttpCore
>          Issue Type: Bug
>          Components: HttpCore
>    Affects Versions: 5.3.6
>            Reporter: Jared Jacobs
>            Priority: Major
>
> When a path contains escaped characters, {{getPath()}} incorrectly returns 
> them unescaped.
> Note that {{toString()}} correctly returns the characters escaped. 
> {{getPath()}} should behave like {{toString()}} in this regard.
> {code:java}
> @Test
> void testUriBuilder() throws URISyntaxException {
>     String path = "/a/b/zzz%2Fzzz/c/d";
>     assertEquals(new URIBuilder(path).toString(), path);
>     assertEquals(new URIBuilder(path).getPathSegments(), List.of("a", "b", 
> "zzz/zzz", "c", "d"));
>     assertEquals(new URIBuilder(path).getPath(), path);
> } {code}
> The last {{assertEquals}} above fails with:
> {quote}{{Expected: /a/b/zzz%2Fzzz/c/d}}
> {{Actual:   /a/b/zzz/zzz/c/d}}
> {quote}
> As you can see, failing to escape path segments can break a URL by, for 
> example, introducing new path segments by subdividing a path segment with new 
> (unescaped) slashes.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to