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

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

> As you can see, failing to escape path segments can break a URL

[~jaredjacobs] No, it does not. The URI itself gets encoded as per requirements 
of RFC 3986. The individual component getters and setters expect and produce 
decoded content. #getPath does exactly what it is expected to do. Those people 
who need silliness like '/' character in their path segments can still use 
#getPathSegments if they desire so.

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