Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 356466

Summary: HostReachableValidator: encoding of URLs is broken
Product: z_Archived Reporter: Michael Ochmann <michael.ochmann>
Component: SkalliAssignee: Project Inbox <skalli.core-inbox>
Status: RESOLVED FIXED QA Contact:
Severity: major    
Priority: P3    
Version: unspecified   
Target Milestone: ---   
Hardware: All   
OS: All   
Whiteboard:

Description Michael Ochmann CLA 2011-09-01 08:53:26 EDT
URLs of the form http://host:port/path%20with%20blanks are encoded as http://host:port/path%2520with%2520blanks which is wrong
Comment 1 Michael Ochmann CLA 2012-07-18 09:36:05 EDT
* URLs entered for projects sometimes are "slightly" invalid, e.g.
contain blanks in paths; browsers usually try to "sanitize" such URLs,
and so should HostReachableValidator
* encoding of URLs/URIs in Java is a mess:
java.net.URI(String) accepts only 100% valid URIs, while
java.net.URI(String, String,...) encodes path and query parameters;
java.net.URL(String) happily accepts for example paths with blanks,
and returns these paths with blanks
* implemented a simple "sanitize" mechanism in URLUtils#stringToURL():
- first try java.net.URI(String) : if the string is a valid URI, just
convert the URI to an URL and return it
- if java.net.URI(String) throws an exception, try
java.net.URL(String): if that fails too, then give up; otherwise
construct a URI with ava.net.URI(String, String,...) and retrieve
the necessary params from the URL: now they are properly encoded!
- finally convert the URI back to an URL using URI#toAsciiString()

https://git.eclipse.org/r/#/c/6844/