allthingssecurity opened a new pull request, #28713: URL: https://github.com/apache/camel/pull/28713
# Description [CAMEL-26308](https://issues.apache.org/jira/browse/CAMEL-26308) `iif` was added in CAMEL-21081 (4.8.0) with tests where quoted true and false values give the text inside the quotes. Since CAMEL-22204 (4.10.7, 4.13.0) the arguments of `iif` are split keeping their quotes (`splitSafeQuote(values, ',', true, true)`), so that a quoted value in the predicate (`${file:name} startsWith 'test'`) survives. The true and false values kept their quotes too, and each is a Simple expression whose text then includes them. `val` (CAMEL-23047, 4.18.1) has passed its argument on with the quotes since it was added: ``` ${iif(${header.foo} > 0,'positive','negative')} -> 'positive' (the documented example; before 4.10.7: positive) ${header.foo > 0 ? 'positive' : 'negative'} -> positive (the ternary operator) ${iif(${header.foo} > 0,'yes','no')} == 'yes' -> false (when foo > 0) ${val('Hello')} -> 'Hello' ``` The Simple functions page gives the `iif` example with quoted values and says the same example is used with the ternary operator, whose section says it returns `positive`; the catalog examples say `${iif(${header.admin} == true,'Admin','User')} -> Admin` and `${val('Hello')} -> Hello`. csimple (removed in 4.23) returned the text without the quotes for both functions. This partly reverts CAMEL-22204, so for the record: its PR (#18483) argued that quotes should be a legal part of the true and false expressions, and changed the existing `testIif` assertions to unquoted values; `MiscFunctionFactoryTest` (CAMEL-22894) later pinned the quoted result, in the same commit that pinned the csimple code for the same input to `"yes"`. The predicate fix of CAMEL-22204 is kept. This PR goes with the documented behaviour, which is also what the original `iif` tests, the ternary operator and `concat` (which splits the same way and then removes the quotes) do. If the quoted result is the intended one, the docs and the catalog examples should change instead, and this PR can be closed. Changes: - `MiscFunctionFactory`: the true and false values of `iif` are taken without their leading and ending quotes (`StringHelper.removeLeadingAndEndingQuotes`, as `concat` does with its arguments). The predicate keeps its quotes. - `StringFunctionFactory`: the same for the argument of `val`. - Values without quotes and functions (`${body}`, `${null}`) are unchanged. - Upgrade guide (4.24): `=== camel-core - Simple: iif and val return a quoted literal without its quotes`, for routes that removed the quotes themselves or relied on them. Tests: - New `SimpleTest.testIifQuotedLiterals` (the documented example next to the ternary operator, a double-quoted value, a value with a comma, an empty value, `iif` in a template and in a predicate, a function inside the quotes, `val` inside `iif`, a quoted predicate with quoted values) and `StringFunctionFactoryTest.testValQuotedLiteral`; `MiscFunctionFactoryTest.testIifTrue` / `testIifFalse` now expect `yes` / `no`. The four fail on main and pass with the change. - The language tests of camel-core (`org/apache/camel/language/**/*Test`, 876 tests) pass. Run offline on main as of e4c4dbbeb5da (2026-10-20, the date of the local snapshot jars of the other core modules), with camel-core-languages built from source; `MiscFunctionFactory` and `StringFunctionFactory` are the same as on the base of this branch. The formatter and import-sort plugins ran and changed nothing. Other tests that use `iif` or `val` (camel-semantic, camel-jsonpath, camel-sql stored, camel-yaml-dsl `SimpleInitBlockTest`) use unquoted values; GitHub code search finds no `iif` in camel-kamelets or the Camel example repositories. Backport: main only, as users can notice the change. The same behaviour is on 4.10.x (`iif` from 4.10.7), 4.14.x, 4.18.x (`iif`, and `val` from 4.18.1), 4.22.x and 4.23.x; up to 4.18.x the code is in `SimpleFunctionExpression`, so a backport would not be a cherry-pick. How it was found: running every example of the Simple catalog metadata (`SimpleConstants`, "expression -> result") through the language and comparing with the documented result. Two documentation slips found the same way are not changed here (`concat('Hello',' ','World')` uses the third argument as the separator, `date-with-timezone(...)` is written `date-with-timezone:...`). The JVM model in Rocq that executes Camel's class files was not used for this one (the Simple language needs a CamelContext). # Target - [x] I checked that the commit is targeting the correct branch (Camel 4 uses the `main` branch) # Tracking - [x] If this is a large change, bug fix, or code improvement, I checked there is a [JIRA issue](https://issues.apache.org/jira/browse/CAMEL-26308) filed for the change (usually before you start working on it): [CAMEL-26308](https://issues.apache.org/jira/browse/CAMEL-26308). # Apache Camel coding standards and style - [x] I checked that each commit in the pull request has a meaningful subject line and body. - [ ] I have run `mvn clean install -DskipTests` locally from root folder and I have committed all auto-generated changes. (I ran the tests above with the formatter and import-sort plugins; no option or catalog metadata changed. I did not run the full root build.) # AI-assisted contributions - [x] If this PR includes AI-generated code, commits have proper co-authorship attribution (e.g., `Co-authored-by` trailers) and the PR description identifies the AI tool used. This PR was prepared with Claude Code (Claude Opus 5.5). The commit carries a `Co-Authored-By` trailer. _Claude Code on behalf of allthingssecurity_ 🤖 Generated with [Claude Code](https://claude.com/claude-code) -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
