[
https://issues.apache.org/jira/browse/CAMEL-15410?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17311362#comment-17311362
]
Claus Ibsen commented on CAMEL-15410:
-------------------------------------
Hi Jeremy
I didnt spot your comment. There is a post on dev mailing list.
Yes URL encoding is sadly yet another thing in IT that is ambiguous and can
cause problems.
The rule about + is for HTML forms, with content-type:
application/x-www-form-urlencoded
https://www.w3.org/TR/1999/REC-html401-19991224/interact/forms.html#h-17.13.4.1
The percent encoding with %20 as space is something all HTTP servers is capable
of doing, so using %20 in URLs is safe.
The special + rule is only for HTTP and something that potentially servers may
struggle with. It may be that they only decode + as space, if there is a HTTP
header with:
Content-Type: application/x-www-form-urlencoded
And Camel would not send that by default. Also if you use HTTP POST with
content in the message body, and query parameters also in the URI that has
spaces, then what Content-Type should you use? ie. if the HTTP POST body is
json data.
For non HTTP components then decimal encoding space as %20 makes it consistent
sql:my-database?select%20from%20myorders
vs
sql:my-database?select+from+myorders
And especially if the query ends up with + to be used as plus, eg
For example if you could so something ala (yes its not correct SQL)
sql:my-database?update ages set age = age + 2
Then it would be encoded as
sql:my-database?update+ages+set+age+%3D+age+%2B+2
And in pure decimal it would be
sql:my-database?update%20ages%20set%20age%20%3D%20age%20%2B%202
When you see % decimail encoding then you know its encoded, but if you do not
and see a plus sign you may think its the math operator
to("foo:bar?beer=2+3")
> REST endpoint has inconsistent URL Encoding
> --------------------------------------------
>
> Key: CAMEL-15410
> URL: https://issues.apache.org/jira/browse/CAMEL-15410
> Project: Camel
> Issue Type: Bug
> Components: rest
> Affects Versions: 3.4.2
> Reporter: Kris Boutilier
> Assignee: Claus Ibsen
> Priority: Major
> Fix For: 3.10.0
>
>
> When passing query parameters to a REST producer the encoding behavior is
> inconsistent. Consider the following:
> {code:java}
> .to("rest:get:bw-web-api/v1/objects/employees?host=agresso&companyId=RD&select=personId,personName&disconnect=true")
> {code}
> The resulting request payload, as observed with Wireshark, is:
> {code:java}
> GET
> /bw-web-api/v1/objects/employees?companyId=RD&disconnect=true&select=personId%252CpersonName
> HTTP/1.1\r\n{code}
> Note that the comma has been double-encoded resulting in transmission of
> %252C instead of the expected %2C.
> If instead the problem string is passed as a parameter via a header, the
> comma is correctly encoded:
> {code:java}
> .setHeader("select", simple("personId,personName"))
> .to("rest:get:bw-web-api/v1/objects/employees?host=agresso&companyId=RD&select={select}&disconnect=true")
> {code}
>
--
This message was sent by Atlassian Jira
(v8.3.4#803005)