Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #28390

Re: [LONG] java.net.URI encoding weirdness

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From Steven Simpson <ss@domain.invalid>
Newsgroups comp.lang.java.programmer
Subject Re: [LONG] java.net.URI encoding weirdness
Date Tue, 06 May 2014 08:47:09 +0100
Organization A noiseless patient Spider
Lines 32
Message-ID <tkgm3b-8p5.ln1@s.simpson148.btinternet.com> (permalink)
References <lk82m6$hhi$1@dont-email.me> <lk8n0o$ibf$1@dont-email.me> <lk8u3d$agp$1@dont-email.me> <lk9861$dk5$1@dont-email.me> <lka2s0$kma$1@dont-email.me>
Mime-Version 1.0
Content-Type text/plain; charset=windows-1252; format=flowed
Content-Transfer-Encoding 7bit
Injection-Info mx05.eternal-september.org; posting-host="c7172f225496c36b8678c3c0744c2347"; logging-data="28270"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/MELyt25neqF+3dU+4x5X3tC2Pepsoahk="
User-Agent Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.5.0
In-Reply-To <lka2s0$kma$1@dont-email.me>
Cancel-Lock sha1:gKHohfnQdGWBMR+lpY1bgM297YI=
Xref csiph.com comp.lang.java.programmer:28390

Show key headers only | View raw


On 06/05/14 08:26, Stanimir Stamenkov wrote:
> The original URI 'u' is:
>
> http://server1/path?param%3D1=value%261&param%3F2=value%232#fragment
>
> Then the URI 'v' which is constructed with all decoded arguments becomes:
>
> http://server2/path?param=1=value&1&param?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&param%253F2=value%25232#fragment 
>

This rings a bell.  I was finding URI's multi-arg constructors useless.  
Since the query string must be submitted as a unit, it must already be 
using & and =, and any special characters in it that are to be taken 
literally must already be encoded, yet the constructor treats it as 
unencoded, and adds another level of encoding.  That also goes for your 
userInfo component with an @ in it to separate user and domain.

I think the solution for me was just to use URLEncoder, concatenate the 
strings, then pass to URI.create().




-- 
ss at comp dot lancs dot ac dot uk

Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

[LONG] java.net.URI encoding weirdness Stanimir Stamenkov <s7an10@netscape.net> - 2014-05-05 16:11 +0300
  Re: [LONG] java.net.URI encoding weirdness Mike Amling <mamling@chaff.us> - 2014-05-05 11:37 -0500
    Re: [LONG] java.net.URI encoding weirdness Mike Amling <mamling@chaff.us> - 2014-05-05 11:43 -0500
    Re: [LONG] java.net.URI encoding weirdness Stanimir Stamenkov <s7an10@netscape.net> - 2014-05-05 19:50 +0300
  Re: [LONG] java.net.URI encoding weirdness markspace <markspace@nospam.nospam> - 2014-05-05 11:58 -0700
    Re: [LONG] java.net.URI encoding weirdness Stanimir Stamenkov <s7an10@netscape.net> - 2014-05-05 23:59 +0300
      Re: [LONG] java.net.URI encoding weirdness markspace <markspace@nospam.nospam> - 2014-05-05 16:51 -0700
        Re: [LONG] java.net.URI encoding weirdness Stanimir Stamenkov <s7an10@netscape.net> - 2014-05-06 10:26 +0300
          Re: [LONG] java.net.URI encoding weirdness Steven Simpson <ss@domain.invalid> - 2014-05-06 08:47 +0100
            Re: [LONG] java.net.URI encoding weirdness Stanimir Stamenkov <s7an10@netscape.net> - 2014-05-06 11:02 +0300
          Re: [LONG] java.net.URI encoding weirdness markspace <markspace@nospam.nospam> - 2014-05-06 10:24 -0700
            Re: [LONG] java.net.URI encoding weirdness Stanimir Stamenkov <s7an10@netscape.net> - 2014-05-06 22:24 +0300
            Re: [LONG] java.net.URI encoding weirdness markspace <markspace@nospam.nospam> - 2014-05-06 12:24 -0700
              Re: [LONG] java.net.URI encoding weirdness Stanimir Stamenkov <s7an10@netscape.net> - 2014-05-06 22:34 +0300
                Re: [LONG] java.net.URI encoding weirdness markspace <markspace@nospam.nospam> - 2014-05-06 13:04 -0700
                Re: [LONG] java.net.URI encoding weirdness Stanimir Stamenkov <s7an10@netscape.net> - 2014-05-06 23:07 +0300
              Re: [LONG] java.net.URI encoding weirdness Stanimir Stamenkov <s7an10@netscape.net> - 2014-05-06 23:04 +0300
            Re: [LONG] java.net.URI encoding weirdness Steven Simpson <ss@domain.invalid> - 2014-05-06 20:29 +0100
              Re: [LONG] java.net.URI encoding weirdness markspace <markspace@nospam.nospam> - 2014-05-06 13:01 -0700

csiph-web