davsclaus commented on code in PR #26637:
URL: https://github.com/apache/camel/pull/26637#discussion_r4058111148


##########
dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/ai/EndpointChecks.java:
##########
@@ -326,6 +326,14 @@ static void checkRegexOptions(List<String> errors, String 
fullUri, int uriLineId
             if (!name.equals("include") && !name.equals("exclude") || 
value.startsWith("{{")) {
                 continue;
             }
+            if (value.contains("\\\\")) {

Review Comment:
   Narrowed in b4bac855dd2a: the check now only fires when the doubled 
backslash precedes a character that a single backslash would escape in a regex 
(`.`, `d`/`s`/`w`, `(`, `[`, `+`, `*`, etc.). `.*\\myfile.*` is left alone: 
`\myfile` is not a valid regex escape, so a literal backslash is the only thing 
it can mean. Added that case to the test. (For the record `include`/`exclude` 
match against `file.getName()`, the bare file name, so a literal backslash is 
essentially never intended, but the narrower check costs nothing.)
   
   _Claude Code on behalf of @davsclaus_
   



##########
dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/ai/EndpointChecks.java:
##########
@@ -326,6 +326,14 @@ static void checkRegexOptions(List<String> errors, String 
fullUri, int uriLineId
             if (!name.equals("include") && !name.equals("exclude") || 
value.startsWith("{{")) {
                 continue;
             }
+            if (value.contains("\\\\")) {
+                // '.*\\.json$' in single quotes: YAML keeps both backslashes, 
and the regex then matches a file name
+                // with a literal backslash, so no file matches and the route 
runs in silence (CAMEL-24854)
+                errors.add(linePrefix(optionLineMap.getOrDefault(name, 
uriLineIdx)) + fullUri.substring(0, colon) + ": "
+                           + name + "=" + value + " matches a backslash in the 
file name (in single quotes one backslash"
+                           + " escapes the dot): write " + name + "='" + 
value.replace("\\\\", "\\") + "'");

Review Comment:
   Agreed, the parenthetical described YAML wrongly. The message now reads: 
`include=.*\\.json$ matches a literal backslash in the file name (in a regex \\ 
is one backslash and \. is a dot): write include='.*\.json$'` — it explains the 
regex, not YAML. Same fix (b4bac855dd2a) covers the other wording thread.
   
   _Claude Code on behalf of @davsclaus_
   



##########
dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/ai/EndpointChecks.java:
##########
@@ -326,6 +326,14 @@ static void checkRegexOptions(List<String> errors, String 
fullUri, int uriLineId
             if (!name.equals("include") && !name.equals("exclude") || 
value.startsWith("{{")) {
                 continue;
             }
+            if (value.contains("\\\\")) {
+                // '.*\\.json$' in single quotes: YAML keeps both backslashes, 
and the regex then matches a file name
+                // with a literal backslash, so no file matches and the route 
runs in silence (CAMEL-24854)
+                errors.add(linePrefix(optionLineMap.getOrDefault(name, 
uriLineIdx)) + fullUri.substring(0, colon) + ": "
+                           + name + "=" + value + " matches a backslash in the 
file name (in single quotes one backslash"
+                           + " escapes the dot): write " + name + "='" + 
value.replace("\\\\", "\\") + "'");

Review Comment:
   Reworded in b4bac855dd2a, see the reply on the sibling thread.
   
   _Claude Code on behalf of @davsclaus_
   



-- 
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]

Reply via email to