Issue Details (XML | Word | Printable)

Key: HTTPCLIENT-588
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: Unassigned
Reporter: Gordon Mohr
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
HttpComponents HttpClient

relative URIs with internal double-slashes ('//') misparsed

Created: 16/Jun/06 08:58 AM   Updated: 03/Jan/08 12:16 PM
Return to search
Component/s: HttpClient
Affects Version/s: 3.0.1
Fix Version/s: 3.1 Alpha 1

Time Tracking:
Not Specified

File Attachments:
  Size
Text File Licensed for inclusion in ASF works httpclient-588.patch 2006-06-17 07:17 AM Gordon Mohr 2 kB
Issue Links:
Reference
 

Resolution Date: 21/Jun/06 06:10 PM


 Description  « Hide
URI.parseUriReference()'s heuristic for interpreting URI parts is thrown off by relative URIs which include an internal '//'. As a result, portions of the supplied relative URI (path) can be lost.

For example:

URI rel = new URI("foo//bar//baz");
rel.toString();
(java.lang.String) //bar//baz

The culprit seems to be line 1961 of URI improperly concluding that two slashes later than the beginning of 'tmp' are still indicative the URI is a 'net_path'.

A possible quick fix might be to add a '!isStartedFromPath &&' to the beginning of the line 1961 test, making the line:

            if (!isStartedFromPath && at + 2 < length && tmp.charAt(at + 1) == '/') {

... and thus preventing the misguided authority-parsing from happening when earlier analysis already identified the current string as a strictly path-oriented URI.

(It also appears the setting of the is_net_path boolean at the end of this if's block may be wrong; this code is run for hier_path URIs that are not net_paths in the 2396 syntax. For example:

URI uri = new URI("http://www.example.com/some/page");
uri.isNetPath();
 (boolean) true

)

 All   Comments   Work Log   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
No work has yet been logged on this issue.