Claus Ibsen created CAMEL-24964:
-----------------------------------

             Summary: simple - tokenizer and predicate parser fixes (quotes, 
braces, chain, ~> in text)
                 Key: CAMEL-24964
                 URL: https://issues.apache.org/jira/browse/CAMEL-24964
             Project: Camel
          Issue Type: Sub-task
          Components: camel-core
            Reporter: Claus Ibsen
            Assignee: Claus Ibsen
             Fix For: 4.23.0


Parser/tokenizer bugs in SimplePredicateParser, SimpleExpressionParser, 
SimpleTokenizer and SimpleSyntaxHints.

* (verified) A {{'}} inside a function makes the predicate silently wrong: 
{{${body.replace("'", "")} == 'x'}} is true for any body. 
removeIgnorableWhiteSpaceTokens flips the quote flag on a quote that is inside 
a function, so the spaces around == become literals. Only flip quote when 
functionCount == 0.
* (verified) A {{}}} inside double quotes breaks what follows: {{${body} 
contains "}" && ${header.foo} == 'y'}} fails with "Logical operator && does not 
support left hand side token". Only single quotes are tracked and functionCount 
goes to -1. Decrement only when functionCount > 0 (as CAMEL-24771 did in 
createNode).
* (verified) A chain followed by a number or null fails: {{${body} ~> 
${length()} > 5}} gives "Unexpected token 5", same for {{== null}}. 
SimplePredicateParser ~830 uses expectAndAcceptMore(whiteSpace) and the outer 
loop then skips the operator token.
* (verified) {{~>}} is recognised anywhere without spaces: template text {{Move 
A~>B}} fails ("expected symbol whiteSpace"), and {{${body.replace('~>', '-')}}} 
fails with "${ cannot accept ~>". Regression since CAMEL-22899, where this was 
plain text. Same for {{ ?: }} inside a function in expression mode.
* (verified) SimpleSyntaxHints.wrapComparison ignores quotes: {{${body == 'a > 
b'}}} is rewritten to {{${body == 'a} > b'}} and fails.
* (verified) Inconsistent unquoted literals: {{${header.foo} == a5}} parses but 
{{== ab}} fails; minusValue() consumes a token without checking for '-', so the 
error index points at the wrong character.
* Low: nested SimpleIllegalSyntaxException from the ternary sub-parse is 
re-wrapped with index -1; the caret is misaligned for multi-line expressions; 
infix operators only accept a literal space (not tab/newline) around them.
* Low: SimpleFunctionStart.tryParseTernaryExpression does not require spaces 
around ? and :, so text such as {{method=at(10:30)}} can be split as a ternary.

_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)

Reply via email to