Path: csiph.com!usenet.pasdenom.info!aioe.org!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Stanimir Stamenkov Newsgroups: comp.lang.java.programmer Subject: Re: [LONG] java.net.URI encoding weirdness Date: Tue, 06 May 2014 10:26:56 +0300 Organization: A noiseless patient Spider Lines: 57 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 8bit Injection-Date: Tue, 6 May 2014 07:26:56 +0000 (UTC) Injection-Info: mx05.eternal-september.org; posting-host="9f3b1682542d0f283a9d005dcd9bed05"; logging-data="21194"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/wiLgcrqyp080E7IW4oPDf" User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:29.0) Gecko/20100101 Firefox/29.0 SeaMonkey/2.26 In-Reply-To: X-Face: "@)%Vlap6d%OVYDS}B4YUWE@yUy+^!w/+.q.,c5kjI#+uG?kYP&r/pTjNWgo:g[A,O=AL3/ j&4Le2cau$ work. Could you share your exact test? And no, my tests didn't use all encoded values – here's one of the examples, once again: public class URITest3 { public static void main(String[] args) throws Exception { URI u = URI.create("http://server1/path" + "?param%3D1=value%261¶m%3F2=value%232" + "#fragment"); System.out.println(u.toASCIIString()); URI v = new URI(u.getScheme(), u.getUserInfo(), "server2", u.getPort(), u.getPath(), u.getQuery(), u.getFragment()); System.out.println(v.toASCIIString()); URI w = new URI(u.getScheme(), u.getRawUserInfo(), "server3", u.getPort(), u.getRawPath(), u.getRawQuery(), u.getRawFragment()); System.out.println(w.toASCIIString()); } } The original URI 'u' is: http://server1/path?param%3D1=value%261¶m%3F2=value%232#fragment Then the URI 'v' which is constructed with all decoded arguments becomes: http://server2/path?param=1=value&1¶m?2=value%232#fragment Note how the 'query' is wrong now. However, the URI 'w' which uses the encoded arguments is also wrong: http://server3/path?param%253D1=value%25261¶m%253F2=value%25232#fragment -- Stanimir