[
https://issues.apache.org/jira/browse/HTTPCORE-787?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Oleg Kalnichevski resolved HTTPCORE-787.
----------------------------------------
Resolution: Invalid
> 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]