[
https://issues.apache.org/jira/browse/CAMEL-24854?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Claus Ibsen updated CAMEL-24854:
--------------------------------
Component/s: camel-jbang
(was: camel-yaml-dsl)
Description:
(Corrected: the validator's backslash hint is right, it says to write
{{'.*\\.json$'}} with one backslash. What went wrong is the next step.)
After the hint for {{include: ".*\\.json$"}} (an unknown escape in double
quotes), the model wrote
{code:yaml}
include: '.*\\\\.json$'
{code}
doubling the backslash as a Java string would, and inside single quotes YAML
keeps both: the regex {{.*\\\\.json$}} matches a file name containing a literal
backslash, so no file matched and the route ran ten seconds in silence (series
l3, content-based-router). A person used to Java strings makes the same slip.
The endpoint checks (EndpointChecks.checkRegexOptions, which already parses
include/exclude/antInclude on the file components) should report a value with a
doubled backslash: "include=.*\\\\.json$ matches a backslash in the file name
(in single quotes one backslash escapes the dot): write include='.*\\.json$'".
A test next to the regex option tests.
was:
For a value with an escape the YAML parser rejects, such as
{code:yaml}
include: ".*\\.json$"
{code}
the validator says: {{\\. inside double quotes is an escape character and . is
not one; write the value in single quotes: '.*\\.json$'}}. The rewrite copies
the double-quoted text verbatim, but inside single quotes YAML does not process
backslashes: {{'.*\\.json$'}} is the regex {{.*\\.json$}}, which matches a file
name containing a literal backslash, so no file matches. In the round-2
benchmark (series l3) the model followed the hint and the route ran ten seconds
in silence, the worst kind of failure.
The rewrite in {{YamlValidator.unknownEscape}} must unescape a doubled
backslash ({{\\\\}} to {{\\}}) when moving the value to single quotes, so the
hint reads {{write the value in single quotes: '.*\\.json$'}} with one
backslash. A test next to the existing one for the hint.
Issue Type: Improvement (was: Bug)
Summary: camel-jbang - the validator reports an include/exclude regex
with a doubled backslash in single quotes, which matches a literal backslash
and so no file (was: camel-yaml-dsl-validator - the hint for a backslash in
double quotes copies the doubled backslash into single quotes, where it becomes
a literal backslash)
> camel-jbang - the validator reports an include/exclude regex with a doubled
> backslash in single quotes, which matches a literal backslash and so no file
> --------------------------------------------------------------------------------------------------------------------------------------------------------
>
> Key: CAMEL-24854
> URL: https://issues.apache.org/jira/browse/CAMEL-24854
> Project: Camel
> Issue Type: Improvement
> Components: camel-jbang
> Reporter: Claus Ibsen
> Priority: Major
>
> (Corrected: the validator's backslash hint is right, it says to write
> {{'.*\\.json$'}} with one backslash. What went wrong is the next step.)
> After the hint for {{include: ".*\\.json$"}} (an unknown escape in double
> quotes), the model wrote
> {code:yaml}
> include: '.*\\\\.json$'
> {code}
> doubling the backslash as a Java string would, and inside single quotes YAML
> keeps both: the regex {{.*\\\\.json$}} matches a file name containing a
> literal backslash, so no file matched and the route ran ten seconds in
> silence (series l3, content-based-router). A person used to Java strings
> makes the same slip.
> The endpoint checks (EndpointChecks.checkRegexOptions, which already parses
> include/exclude/antInclude on the file components) should report a value with
> a doubled backslash: "include=.*\\\\.json$ matches a backslash in the file
> name (in single quotes one backslash escapes the dot): write
> include='.*\\.json$'". A test next to the regex option tests.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)