You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@camel.apache.org by "Claus Ibsen (Jira)" <ji...@apache.org> on 2026/09/17 19:17:00 UTC
[jira] [Commented] (CAMEL-24802) camel-core - simple: add escape function for html/xml/json/sql/url special characters
[ https://issues.apache.org/jira/browse/CAMEL-24802?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18116468#comment-18116468 ]
Claus Ibsen commented on CAMEL-24802:
-------------------------------------
PR: https://github.com/apache/camel/pull/26565
_Claude Code on behalf of davsclaus_
> camel-core - simple: add escape function for html/xml/json/sql/url special characters
> -------------------------------------------------------------------------------------
>
> Key: CAMEL-24802
> URL: https://issues.apache.org/jira/browse/CAMEL-24802
> Project: Camel
> Issue Type: New Feature
> Components: camel-core
> Reporter: Claus Ibsen
> Assignee: Claus Ibsen
> Priority: Major
>
> A user on Zulip needed to escape special characters (& < > quotes etc.) in message data before feeding it to a Velocity template, and observed that the simple language has no function for this. Today you either chain multiple {{replace(...)}} calls, write a custom bean, or resort to {{${bean:...}}} with a helper class such as Velocity's EscapeTool or commons-text StringEscapeUtils.
> Simple already has {{htmlDecode(exp)}} and {{htmlClean(exp)}} but nothing for the encoding/escaping direction.
> Proposal: add an {{escape(kind,exp)}} function (or {{escapeAs(...)}} / individual functions) covering the common kinds:
> * {{html}} - {{& < > " '}}
> * {{xml}} - the five XML entities
> * {{json}} - backslash-escape quotes, backslashes and control characters
> * {{sql}} - double single quotes
> * {{url}} - percent-encoding (application/x-www-form-urlencoded)
> For example:
> {code}
> ${escape(html, ${body})}
> ${escape(xml, ${header.item})}
> {code}
> The {{exp}} argument should be optional and default to the message body, consistent with the other string functions. The implementation should live in camel-core-languages using JDK-only code (no new dependency), and the function must be documented in simple-functions.adoc and picked up by the TUI/MCP catalog function metadata via the {{@Metadata}} annotation in {{SimpleConstants}}.
> See also the related velocity documentation update that shows how to use Velocity's EscapeTool inside a template as the template-side alternative.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)