Bruno Gonçalves created CAMEL-24813:
---------------------------------------

             Summary: camel-core: PropertiesComponent.unescape drops trailing 
backslash
                 Key: CAMEL-24813
                 URL: https://issues.apache.org/jira/browse/CAMEL-24813
             Project: Camel
          Issue Type: Bug
          Components: camel-core
    Affects Versions: 4.22.1, 4.22.0
         Environment: Java 25
Apache Camel 4.22.1
            Reporter: Bruno Gonçalves
         Attachments: setbody-newline-placeholder-reproducer.tar.gz

{{PropertiesComponent.unescape()}} is intended to handle escaped 
property-placeholder braces ({{{}\\{{ / \}}{}}}),
but it also drops a trailing backslash when fewer than 2 characters follow it.

As a result, a route-template / kamelet parameter value ending with the Simple 
escape sequence {{\n}}
(the two characters '\' + 'n') is corrupted during {{{\{expression}}}} 
resolution:

  input:    {{test\n}}
  resolved: {{testn}}

Simple never sees {{{}\n{}}}, so {{setBody().simple("\{{expression}}")}} 
produces the literal body "{{{}testn{}}}"
instead of "{{{}test{}}}" + {{{}LF{}}}.

Mid-string escapes are preserved ({{{}hello\nworld{}}}, {{{}hello\tworld{}}}), 
which makes the bug easy to miss.
Trailing {{\t}} is affected the same way ({{{}test\t{}}} -> {{{}testt{}}}).

This matters for route templates and kamelets that pass Simple expressions via 
{{{}{\{parameters}}{}}}.

*Expected:*
  {{{\{expression}}}} with value {{test\n}} should resolve to {{test\n}} 
(backslash preserved),
  then Simple should evaluate to "{{{}test{}}}" + newline.

*Actual:*
  resolves to {{{}testn{}}}.

*Steps to Reproduce:*
  1. Use the attached/standalone reproducer (Camel 4.22.0), or the snippet 
below.
  2. Run: mvn camel:run
3. Observe PropertiesComponent.parseUri and route-template setBody output.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to