Details
-
Bug
-
Status: Resolved
-
Minor
-
Resolution: Fixed
-
2.8.3
-
None
-
Novice
Description
URI with empty path, but non-empty query part is not properly normalized. The query part is in fact duplicated. E.g, URI "foobar://?foo=1&bar=2" is incorrectly normalized to "foobar://?foo=1&bar=2?bar=2&foo=1".
This is caused by incorrect identification of the path part in org.apache.camel.util.URISupport.normalizeUri(String):
int idx = path.indexOf('?');
if (idx > 0)
The comparison of "idx > 0" is incorrect, because this way, if '?' is the first character, the path is not set to empty string. The correct comparison should be "idx > -1" or "idx >= 0" or even just "idx != -1" since that's the only value that String.indexOf returns when the character is not found.