Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!news-1.dfn.de!news.dfn.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Mike Amling Newsgroups: comp.lang.java.programmer Subject: Re: [LONG] java.net.URI encoding weirdness Date: Mon, 05 May 2014 11:43:04 -0500 Lines: 57 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: individual.net jzjOg6F0w6VEdOzydA6bbw1lboIzaHEqV/n/0lIkCPUTCkKmdC Cancel-Lock: sha1:UVrXcONwG/yXppk/puRBajvwwiM= User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:24.0) Gecko/20100101 Thunderbird/24.4.0 In-Reply-To: Xref: csiph.com comp.lang.java.programmer:28380 On 5/5/14 11:37 AM, Mike Amling wrote: > On 5/5/14 8:11 AM, Stanimir Stamenkov wrote: >> This is a long time observation but I wanted to summarize it and give >> heads up to ones which might not have encountered it, yet. >> ... >> Now, I expect the URI(scheme, authority, path, query, fragment) >> constructor would need a raw 'authority' value as it gets parsed into >> 'userInfo', 'host' and 'port' components/properties: >> >> public class URITest2 { >> >> public static void main(String[] args) throws Exception { >> URI u = URI.create("http://user%40domain@server1:8080" >> + "/path?param=value#fragment"); >> System.out.println(u.toASCIIString()); >> >> URI v = new URI(u.getScheme(), >> u.getAuthority(), >> "/htap", >> u.getQuery(), >> u.getFragment()); >> System.out.println(v.toASCIIString()); >> >> URI w = new URI(u.getScheme(), >> u.getRawAuthority(), >> "/htap", >> u.getQuery(), >> u.getFragment()); >> System.out.println(w.toASCIIString()); >> } >> >> } >> >> The output: >> >> http://user%40domain@server1:8080/path?param=value#fragment >> http://user@domain@server1:8080/htap?param=value#fragment >> http://user%2540domain@server1:8080/htap?param=value#fragment >> >> shows there's no way to re-construct a correct URI using it. >> >> ... TL;DR > > Looks like you need > > URI v = new URI( > u.getScheme(), > u.getAuthority().someKindOfEncodeFunction(), > "/htap", > u.getQuery(), > u.getFragment()); Oh, no, that won't work, either. Sorry. Mike Amling -- T29wcw==