gnodet-bot commented on code in PR #26637:
URL: https://github.com/apache/camel/pull/26637#discussion_r4058089353


##########
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:
   💬 **Wording nit — the parenthetical is misleading to the user.**
   
   The current message says: `"matches a backslash in the file name (in single 
quotes one backslash escapes the dot)"`. The parenthetical tries to explain 
*why* the single-backslash form is correct, but it conflates YAML and regex 
semantics: in YAML single-quoted scalars, backslash has *no* special meaning at 
all — `'.*\.json$'` is the literal string `.*\.json$` (one backslash before the 
dot). The regex engine then interprets `\.` as an escaped dot, matching only a 
literal dot. The message should explain the *regex* meaning, not imply YAML 
performs any escaping.
   
   Suggested replacement:
   
   ```suggestion
                              + name + "=" + value + " matches a literal 
backslash in the file name; write "
                              + " " + name + "='" + value.replace("\\\\", "\\") 
+ "' (one backslash: \\. matches a dot in the regex)");
   ```



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