shashank created CAMEL-26465:
--------------------------------

             Summary: camel-core - Simple: function arguments drop an empty 
argument, and a comma inside a nested function splits an argument
                 Key: CAMEL-26465
                 URL: https://issues.apache.org/jira/browse/CAMEL-26465
             Project: Camel
          Issue Type: Bug
          Components: camel-core
            Reporter: shashank
            Assignee: shashank


Found while reviewing CAMEL-26420; the same before it.

{{SimpleFunctionHelper.splitArguments}} (used by {{replace}}, {{substring}}, 
the collection functions and others) and, since CAMEL-26420, 
{{JoinFunctionFactory}} (its own call of the same split, so it can keep the 
separator as written) split with {{StringQuoteHelper.splitSafeQuote(values, 
',', false, true)}}, which drops an empty argument and does not look at nesting:
* an empty argument is dropped, so the next argument takes its place: 
{{${replace(b,,${header.s})}}} uses the expression as the replacement, 
{{${join(,id=)}}} uses {{id=}} as the separator, {{${join(&,,${body})}}} uses 
the text {{${body}}} as the prefix;
* a comma inside a nested function splits the argument: 
{{${replace(b,${header.s.substring(1,3)})}}} replaces with {{3)}}}, 
{{${join(&,id=,${substring(1,2)})}}} is refused as more than 3 arguments, and 
{{sort}} / {{distinct}} with such an argument fail to parse ({{splitSafeQuote}} 
with {{nested=true}} keeps the nested function together).

For {{join}} only: {{${join(,,)}}} fails with {{Index 0 out of bounds}} instead 
of the "Valid syntax" message, and {{${join( )}}} gives the default separator, 
as the arguments are checked with {{isNotEmpty}}, which trims.

*Proposal*
Split with nesting and keep empty arguments in {{splitArguments}} and in the 
split of {{join}} (best one shared split method in {{SimpleFunctionHelper}}, 
with tests per function), and give the "Valid syntax" message of {{join}} for a 
malformed argument list.

_Filed with Claude Code on behalf of allthingssecurity._



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to