You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Vojtech Fried <vf...@opentext.com> on 2019/12/10 12:02:08 UTC

URI encoding and RAW values

Hi,

I am trying to understand how the query parameters in Camel component configuration URIs work. I am working specifically with smtp output. I have seen https://camel.apache.org/manual/latest/faq/how-do-i-configure-password-options-on-camel-endpoints-without-the-value-being-encoded.html and https://camel.apache.org/manual/latest/faq/why-cant-i-use-sign-in-my-password.html and I also saw some discussions about it https://camel.465427.n5.nabble.com/Is-RAW-required-in-message-endpoint-URI-with-percent-endcoded-special-characters-td5748784.html

But it seems to me that Camel handles URIs in a wrong way. I would expect that I as a client have to URLEncoder.encode the query parameter values and Camel would then parse the URI, find the parameters and URLDecoder.decode the values. This is not what Camel does though. Camel seems to take the whole query string, decode it and them it starts to parse it (starts to look for parameters). Since it is already decoded, it then does not decode the values. But it is wrong when a parameter value contains e.g. '&' character because the parser has no way to know if it is meant to be a control character (separator of parameters) or just a part of a value. At least this is what I saw in Camel code while debugging. URISupport.parseParameters calls uri.getQuery() which fetches the decoded query part. To fix it, URISupport.parseParameters should take uri.getRawQuery() and in URIScanner.getDecodedValue() it should just decode and not encode the percent chars first. There is probably more to fix, but this is the idea.

The FAQ recommends to use RAW(...). But I think that
1. it should not be needed if URI handling in Camel was correct
2. RAW(...) has limitations of its own. (Try this: 'RAW(%3d&%%))&}&\t=+?)')

Am I missing something?

Vojtech