[
https://issues.apache.org/jira/browse/CAMEL-16016?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17308412#comment-17308412
]
Claus Ibsen commented on CAMEL-16016:
-------------------------------------
Its because the password have % which Camel uses to detect if part of the text
is already decimal encoded, and it happens that %c6 is then a decimal.
Because its a password and you want to use as-is, then you should enclose the
password in RAW style and encode in raw mode enabled, eg this works
{code}
@Test
public void testWrongEncoding(){
String password= "RAW(%j#7%c6i)";
String result = UnsafeUriCharactersEncoder.encode(password, true);
// remove RAW
result = result.substring(4);
result = result.substring(0, result.length() - 1);
String expected = "%25j%237%25c6i";
System.out.println("expected -> "+expected);
System.out.println("vs");
System.out.println(result);
if (!result.equals(expected)){
System.err.println("not the same , no no ");
}
}
{code}
> Encoding special characters via UnsafeUriCharactersEncoder does not work in
> all cases
> -------------------------------------------------------------------------------------
>
> Key: CAMEL-16016
> URL: https://issues.apache.org/jira/browse/CAMEL-16016
> Project: Camel
> Issue Type: Bug
> Components: camel-core
> Affects Versions: 2.20.4, 3.8.0
> Reporter: Pavel Kostelnik
> Priority: Minor
>
> we have the following FTP password:
> {code:java}
> String password= "%j#7%c6i";{code}
> when encoded with camel (*we are using RAW()*) this results in a gibberish
> string with <?> (unprintable characters)
> ==> expected output:
> %25j%237%25c6i
> Sample test demonstrating the bug / reproducer:
> {code:java}
> @Test
> public void testWrongEncoding(){
> String password= "%j#7%c6i";
> String result = UnsafeUriCharactersEncoder.encode(password);
> String expected = "%25j%237%25c6i";
> System.out.println("expected -> "+expected);
> System.out.println("vs");
> System.out.println(result);
> if (!result.equals(expected)){
> System.err.println("not the same , no no ");
> }
> }
> {code}
>
--
This message was sent by Atlassian Jira
(v8.3.4#803005)