You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Stephen Cameron <st...@gmail.com> on 2014/04/22 06:17:17 UTC
URI encoding is giving me problems
Hi,
I have a plus (+) symbol in a parameter value that is being converted to a
space. When I encode this as %2B it still ends up as a space in the
parameter value.
In fact, both %20 and %2B end up giving me spaces in the parameter value.
The following shows the issue
DefaultCamelContext context = new DefaultCamelContext();
MockComponent comp = new MockComponent();
comp.setCamelContext(context);
EndpointConfiguration conf = comp.createConfiguration("test:
https://test.com?secretKey=A%2B-%20A");
System.out.println(conf.getParmeter("secretKey"));
conf.setParameter("secretKey","A+- A");
System.out.println(conf.getParmeter("secretKey"));
Output is:
A - A
A+- A
The first should be the same as the second.
Thanks
Steve Cameron
Re: URI encoding is giving me problems
Posted by Stephen Cameron <st...@gmail.com>.
Thanks,
RAW does solve my problem, but it does seem strange that its necessary. A
trap for new players.
On Fri, Apr 25, 2014 at 3:51 AM, Aki Yoshida <el...@gmail.com> wrote:
> @Claus
>
> I think there is something strange with the encoding/decoding logic,
> concretely speaking, what URISupport's parseQuery does.
> what I find it strange is that the query string passed from URI to the
> EndpointConfiguration is already decoded, as URI decodes it.
> So decoding it again when setting this value within EC as it is done
> currently will double-decode %2B, no?
>
> I don't think the RAW mode was necessary.
> Also strange and appears incorrect in this method is the way how the
> raw mode is detected (i.e., the string buffer's toString is gets
> repeatedly invoked).
>
> How do you think?
> regards, aki
>
>
> 2014-04-22 9:03 GMT+02:00 <Ra...@cognizant.com>:
> > Claus
> >
> > Even after adding RAW the output of key still comes as RAW(+) and not
> only + as expected.
> >
> > addParameter method of URISupport class should strip out the RAW() and
> just retain + against passwd.
> >
> > Here is what I tried.
> >
> > EndpointConfiguration conf =
> comp.createConfiguration("test:https://test.com?PASSWD=RAW(+)");
> > System.out.println(conf.getParameter("PASSWD"));
> >
> > Any idea what is missing ?
> >
> > -----Original Message-----
> > From: Claus Ibsen [mailto:claus.ibsen@gmail.com]
> > Sent: Tuesday, April 22, 2014 10:51 AM
> > To: users@camel.apache.org
> > Subject: Re: URI encoding is giving me problems
> >
> > Hi
> >
> > See this FAQ
> >
> http://camel.apache.org/how-do-i-configure-password-options-on-camel-endpoints-without-the-value-being-encoded.html
> >
> > On Tue, Apr 22, 2014 at 6:17 AM, Stephen Cameron <
> steve.cameron.62@gmail.com> wrote:
> >> Hi,
> >>
> >> I have a plus (+) symbol in a parameter value that is being converted
> >> to a space. When I encode this as %2B it still ends up as a space in
> >> the parameter value.
> >>
> >> In fact, both %20 and %2B end up giving me spaces in the parameter
> value.
> >>
> >> The following shows the issue
> >>
> >> DefaultCamelContext context = new DefaultCamelContext(); MockComponent
> >> comp = new MockComponent(); comp.setCamelContext(context);
> >> EndpointConfiguration conf = comp.createConfiguration("test:
> >> https://test.com?secretKey=A%2B-%20A");
> >> System.out.println(conf.getParmeter("secretKey"));
> >> conf.setParameter("secretKey","A+- A");
> >> System.out.println(conf.getParmeter("secretKey"));
> >>
> >> Output is:
> >>
> >> A - A
> >> A+- A
> >>
> >> The first should be the same as the second.
> >>
> >> Thanks
> >> Steve Cameron
> >
> >
> >
> > --
> > Claus Ibsen
> > -----------------
> > Red Hat, Inc.
> > Email: cibsen@redhat.com
> > Twitter: davsclaus
> > Blog: http://davsclaus.com
> > Author of Camel in Action: http://www.manning.com/ibsen
> > hawtio: http://hawt.io/
> > fabric8: http://fabric8.io/
> > This e-mail and any files transmitted with it are for the sole use of
> the intended recipient(s) and may contain confidential and privileged
> information. If you are not the intended recipient(s), please reply to the
> sender and destroy all copies of the original message. Any unauthorized
> review, use, disclosure, dissemination, forwarding, printing or copying of
> this email, and/or any action taken in reliance on the contents of this
> e-mail is strictly prohibited and may be unlawful.
>
Re: URI encoding is giving me problems
Posted by Aki Yoshida <el...@gmail.com>.
@Claus
I think there is something strange with the encoding/decoding logic,
concretely speaking, what URISupport's parseQuery does.
what I find it strange is that the query string passed from URI to the
EndpointConfiguration is already decoded, as URI decodes it.
So decoding it again when setting this value within EC as it is done
currently will double-decode %2B, no?
I don't think the RAW mode was necessary.
Also strange and appears incorrect in this method is the way how the
raw mode is detected (i.e., the string buffer's toString is gets
repeatedly invoked).
How do you think?
regards, aki
2014-04-22 9:03 GMT+02:00 <Ra...@cognizant.com>:
> Claus
>
> Even after adding RAW the output of key still comes as RAW(+) and not only + as expected.
>
> addParameter method of URISupport class should strip out the RAW() and just retain + against passwd.
>
> Here is what I tried.
>
> EndpointConfiguration conf = comp.createConfiguration("test:https://test.com?PASSWD=RAW(+)");
> System.out.println(conf.getParameter("PASSWD"));
>
> Any idea what is missing ?
>
> -----Original Message-----
> From: Claus Ibsen [mailto:claus.ibsen@gmail.com]
> Sent: Tuesday, April 22, 2014 10:51 AM
> To: users@camel.apache.org
> Subject: Re: URI encoding is giving me problems
>
> Hi
>
> See this FAQ
> http://camel.apache.org/how-do-i-configure-password-options-on-camel-endpoints-without-the-value-being-encoded.html
>
> On Tue, Apr 22, 2014 at 6:17 AM, Stephen Cameron <st...@gmail.com> wrote:
>> Hi,
>>
>> I have a plus (+) symbol in a parameter value that is being converted
>> to a space. When I encode this as %2B it still ends up as a space in
>> the parameter value.
>>
>> In fact, both %20 and %2B end up giving me spaces in the parameter value.
>>
>> The following shows the issue
>>
>> DefaultCamelContext context = new DefaultCamelContext(); MockComponent
>> comp = new MockComponent(); comp.setCamelContext(context);
>> EndpointConfiguration conf = comp.createConfiguration("test:
>> https://test.com?secretKey=A%2B-%20A");
>> System.out.println(conf.getParmeter("secretKey"));
>> conf.setParameter("secretKey","A+- A");
>> System.out.println(conf.getParmeter("secretKey"));
>>
>> Output is:
>>
>> A - A
>> A+- A
>>
>> The first should be the same as the second.
>>
>> Thanks
>> Steve Cameron
>
>
>
> --
> Claus Ibsen
> -----------------
> Red Hat, Inc.
> Email: cibsen@redhat.com
> Twitter: davsclaus
> Blog: http://davsclaus.com
> Author of Camel in Action: http://www.manning.com/ibsen
> hawtio: http://hawt.io/
> fabric8: http://fabric8.io/
> This e-mail and any files transmitted with it are for the sole use of the intended recipient(s) and may contain confidential and privileged information. If you are not the intended recipient(s), please reply to the sender and destroy all copies of the original message. Any unauthorized review, use, disclosure, dissemination, forwarding, printing or copying of this email, and/or any action taken in reliance on the contents of this e-mail is strictly prohibited and may be unlawful.
RE: URI encoding is giving me problems
Posted by Ra...@cognizant.com.
Claus
Even after adding RAW the output of key still comes as RAW(+) and not only + as expected.
addParameter method of URISupport class should strip out the RAW() and just retain + against passwd.
Here is what I tried.
EndpointConfiguration conf = comp.createConfiguration("test:https://test.com?PASSWD=RAW(+)");
System.out.println(conf.getParameter("PASSWD"));
Any idea what is missing ?
-----Original Message-----
From: Claus Ibsen [mailto:claus.ibsen@gmail.com]
Sent: Tuesday, April 22, 2014 10:51 AM
To: users@camel.apache.org
Subject: Re: URI encoding is giving me problems
Hi
See this FAQ
http://camel.apache.org/how-do-i-configure-password-options-on-camel-endpoints-without-the-value-being-encoded.html
On Tue, Apr 22, 2014 at 6:17 AM, Stephen Cameron <st...@gmail.com> wrote:
> Hi,
>
> I have a plus (+) symbol in a parameter value that is being converted
> to a space. When I encode this as %2B it still ends up as a space in
> the parameter value.
>
> In fact, both %20 and %2B end up giving me spaces in the parameter value.
>
> The following shows the issue
>
> DefaultCamelContext context = new DefaultCamelContext(); MockComponent
> comp = new MockComponent(); comp.setCamelContext(context);
> EndpointConfiguration conf = comp.createConfiguration("test:
> https://test.com?secretKey=A%2B-%20A");
> System.out.println(conf.getParmeter("secretKey"));
> conf.setParameter("secretKey","A+- A");
> System.out.println(conf.getParmeter("secretKey"));
>
> Output is:
>
> A - A
> A+- A
>
> The first should be the same as the second.
>
> Thanks
> Steve Cameron
--
Claus Ibsen
-----------------
Red Hat, Inc.
Email: cibsen@redhat.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen
hawtio: http://hawt.io/
fabric8: http://fabric8.io/
This e-mail and any files transmitted with it are for the sole use of the intended recipient(s) and may contain confidential and privileged information. If you are not the intended recipient(s), please reply to the sender and destroy all copies of the original message. Any unauthorized review, use, disclosure, dissemination, forwarding, printing or copying of this email, and/or any action taken in reliance on the contents of this e-mail is strictly prohibited and may be unlawful.
Re: URI encoding is giving me problems
Posted by Claus Ibsen <cl...@gmail.com>.
Hi
See this FAQ
http://camel.apache.org/how-do-i-configure-password-options-on-camel-endpoints-without-the-value-being-encoded.html
On Tue, Apr 22, 2014 at 6:17 AM, Stephen Cameron
<st...@gmail.com> wrote:
> Hi,
>
> I have a plus (+) symbol in a parameter value that is being converted to a
> space. When I encode this as %2B it still ends up as a space in the
> parameter value.
>
> In fact, both %20 and %2B end up giving me spaces in the parameter value.
>
> The following shows the issue
>
> DefaultCamelContext context = new DefaultCamelContext();
> MockComponent comp = new MockComponent();
> comp.setCamelContext(context);
> EndpointConfiguration conf = comp.createConfiguration("test:
> https://test.com?secretKey=A%2B-%20A");
> System.out.println(conf.getParmeter("secretKey"));
> conf.setParameter("secretKey","A+- A");
> System.out.println(conf.getParmeter("secretKey"));
>
> Output is:
>
> A - A
> A+- A
>
> The first should be the same as the second.
>
> Thanks
> Steve Cameron
--
Claus Ibsen
-----------------
Red Hat, Inc.
Email: cibsen@redhat.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen
hawtio: http://hawt.io/
fabric8: http://fabric8.io/