camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Hadrian Zbarcea <hzbar...@gmail.com>
Subject Re: Ampersand in URI query parameter not working (CAMEL-4857 doesn't fix)
Date Thu, 11 Oct 2012 15:30:14 GMT
I will try to take a look at your example later today. The double 
encoding issue was there from the beginning of camel. Due to the limited 
number of components at the time, we didn't see the edge cases very 
well, and later on we only worked around the once we encountered. 
Realistically, a proper fix will only come in 3.0.

Cheers,
Hadrian

On 10/11/2012 10:40 AM, pmcb55 wrote:
> I have a very simple use-case that seems to highlight a bug in Camel's URI
> handling code. It's very easy to demonstrate, the following code shows the
> problem:
>
>              String query = URLEncoder.encode("D & B", "UTF-8");
>              String endpoint = "https4://www.google.com/?" + query;
>              Exchange response = producerTemplate().send(endpoint, new
> DefaultExchange(context));
>
> The result back from the Google search is only performed on 'D', and not the
> full 'D & B' search term we specified.
>
> I thought this problem might have been resolved by CAMEL-4857, since that is
> a code change in the same area of the code, but downloading and building
> Camel TRUNK doesn't fix this simple problem at all, nor can I see any way it
> can fix the above problem (so I think this is a separate bug completely).
>
> The real problem seems to be located in the following line from the method
> 'normalizeUri(String uri)' in the class 'URISupport.java':
>
> Line 349 (in trunk):         Map<String, Object> parameters =
> URISupport.parseParameters(u);
>
> Within the 'parseParameters()' method, the first line calls
> 'uri.getQuery()', but this decodes the query string, which results in my
> encoded query string above (which is passed into this method correctly as
> '?q=D+%26+B') being decoded to '?q=D+&+B', which is then subsequently parsed
> (in the 'parseQuery(query)' line at 178) as having multiple query params
> ('q=D+' and '+B') when in fact it really only has one ('q=D+%20+B').
>
> I was hoping to make a simple code change to this code (i.e. simply changing
> the above 'uri.getQuery()' call to be 'uri.getRawQuery()' but my trunk
> version fails with a test failure when I run 'mvn clean install' on the
> 'camel-core' POM, see below:
>
> Failed tests:
>
> testPollFileAndShouldBeDeletedAtThirdPoll(org.apache.camel.component.file.From
> FilePollThirdTimeOkTest): mock://result Body of message: 0. Expected: <Hello
> Wor
> ld this file will be deleted> but was: <null>
>
> Tests run: 4322, Failures: 1, Errors: 0, Skipped: 1
>
> Any guidance would be very welcome...
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Ampersand-in-URI-query-parameter-not-working-CAMEL-4857-doesn-t-fix-tp5720914.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>

Mime
View raw message