Details
-
Bug
-
Status: Resolved
-
Major
-
Resolution: Fixed
-
4.5.5
-
None
-
Patch
Description
If original path startsWith '/' it is removed by normalizePath; in that case it should be added again URI-encoded. For example: A path value of '/etc/motd' becomes:
ftp://myname@host.dom/etc/motd
while it should be:
ftp://myname@host.dom/%2Fetc/motd
Only when the path value is 'etc/motd' is should become "ftp://myname@host.dom/etc/motd"
Fix for this issue in URIBuilder.java:
private String buildString() { ... if (this.encodedPath != null) { sb.append(normalizePath(this.encodedPath, sb.length() == 0)); } else if (this.path != null) { String encodedPath = encodePath(normalizePath(this.path, sb.length() == 0)); // Start fix for paths starting with '/' // If original path startsWith '/' it is removed by normalizePath; in that case it should be added again URI-encoded. if (this.path.startsWith("/")) { encodedPath = "/%2F" + encodedPath.substring(1); } // End fix sb.append(encodedPath); } ... }
Attachments
Issue Links
- causes
-
HTTPCLIENT-1968 Encoded forward slashes are not preserved when rewriting URI
- Resolved
-
HTTPCLIENT-1983 URIBuilder normalization change is significantly breaking
- Resolved