[ 
https://issues.apache.org/jira/browse/HTTPCLIENT-691?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12529523
 ] 

Christopher Sahnwaldt commented on HTTPCLIENT-691:
--------------------------------------------------

A small change in URI.parseAuthority() fixes the problem (and hopefully does 
not cause others...)

Here are lines 2215 and 2216 (current SVN version of URI):

// REMINDME: it doesn't need the pre-validation
_host = original.substring(from, next).toCharArray();

Change these lines to

// REMINDME: it doesn't need the pre-validation
_host = (escaped) ? original.substring(from, next).toCharArray()
    : encode(original.substring(from, next), hostname, charset);

and the problem is almost fixed:

bär.de
b%C3%A4r.de
/bär
/b%C3%A4r
bär=eis
b%C3%A4r=eis
false


The raw hostname is now escaped, but URI.isHostname() is still false. Another 
small change fixes that.

Here are lines 1117 to 1119:

hostname.or(toplabel);
// hostname.or(domainlabel);
hostname.set('.');

Add another line so that % is also valid in hostnames:

hostname.or(toplabel);
// hostname.or(domainlabel);
hostname.set('.');
hostname.set('%');

With these changes, the test prints

bär.de
b%C3%A4r.de
/bär
/b%C3%A4r
bär=eis
b%C3%A4r=eis
true



> URI does not handle non-ASCII characters in host names correctly
> ----------------------------------------------------------------
>
>                 Key: HTTPCLIENT-691
>                 URL: https://issues.apache.org/jira/browse/HTTPCLIENT-691
>             Project: HttpComponents HttpClient
>          Issue Type: Bug
>          Components: HttpClient
>            Reporter: Christopher Sahnwaldt
>            Priority: Minor
>
> URI uri = new URI("http://www.eisbär.de/eisbär?eis=bär";, false);
> System.out.println(uri.getHost());
> System.out.println(uri.getPath());
> System.out.println(uri.getQuery());
> prints
> www.eisb?r.de
> /eisbär
> eis=bär

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to