Claus Ibsen created CAMEL-24967:
-----------------------------------
Summary: simple - function argument parsing fixes (quotes, commas,
parentheses, prefixes)
Key: CAMEL-24967
URL: https://issues.apache.org/jira/browse/CAMEL-24967
Project: Camel
Issue Type: Sub-task
Components: camel-core
Reporter: Claus Ibsen
Assignee: Claus Ibsen
Fix For: 4.23.0
Bugs in how function names are matched and arguments are split
(functions/*FunctionFactory, SimpleFunctionHelper). A depth-aware splitter
(tracking quotes, parentheses and ${}) would fix most of these at once.
* (verified) removeQuotes strips every quote, not just the outer ones:
{{${size(${body.split(',')})}}} becomes {{split(,)}}. Affects trim, capitalize,
quote, uppercase, lowercase, length, size, normalizeWhitespace, isEmpty etc.
Use removeLeadingAndEndingQuotes.
* (verified) {{${convertTo(${header.foo.trim()},Integer)}}} is cut at the first
) (ClassNotFoundException: ${header.foo.trim( ). Same for
headerAs/variableAs/bodyAs/messageAs.
* (verified) A comma inside a quoted argument gives
ArrayIndexOutOfBoundsException: {{${throwException('Order failed, retry
later')}}}, {{${concat('Hello, ')}}}. hash splits on a raw comma too.
* (verified) Too few arguments give ArrayIndexOutOfBoundsException instead of a
syntax error: {{${iif(${header.foo} > 0,'yes')}}}, {{${replace(a)}}}. With a
nested ${} it escapes at runtime per exchange.
* (verified) {{${bean:type:java.lang.System.lineSeparator}}} is split at the
first dot (ClassNotFoundException: java). The documented type: form only works
with ?method= or ::.
* (verified) {{${header['a.b']}}} is still treated as OGNL: with header a
present it calls method b on it. Same for variable and exchangeProperty.
* (verified) Prefix-glued names are silently accepted: {{${headerfoo}}} returns
header foo, {{${uuidv7}}} returns a default UUID. Only body and exchange got
the "must be followed by . ? [" guard. Custom functions named e.g. uuidv7 or
headerCount can be registered but are unreachable.
* {{${in.headers.size}}} returns header "size" (only headers.size is
special-cased); propertiesExist:key:junk and empty(...)junk silently ignore the
rest.
* SimpleTest ~867 asserts {{${variableAA('bar', 'int')}}} returns null, which
pins the prefix bug (looks like a typo test).
_Claude Code on behalf of davsclaus (found by an AI review of the simple
language source; each item marked (verified) was reproduced on main at
c3ef718de2e8)_
--
This message was sent by Atlassian Jira
(v8.20.10#820010)