Croway commented on code in PR #30801:
URL: https://github.com/apache/camel/pull/30801#discussion_r4705898829


##########
components/camel-ai/camel-ai-resource/src/main/java/org/apache/camel/component/ai/resource/AiResourceUriTemplate.java:
##########
@@ -144,15 +147,73 @@ public Optional<Map<String, String>> match(String 
resourceUri) {
         Map<String, String> values = new LinkedHashMap<>();
         for (int i = 0; i < variableNames.size(); i++) {
             String value = matcher.group(i + 1);
-            // Dot segments can be normalized by downstream URI/path consumers.
-            if (".".equals(value) || "..".equals(value)) {
+            // Dot segments can be normalized by downstream URI/path 
consumers. RFC 3986 makes %2E equivalent to
+            // ".", and a consumer that decodes the value also turns %2F (or 
%5C) into a path separator.
+            if (containsDotSegment(value)) {
                 return Optional.empty();
             }
             values.put(variableNames.get(i), value);
         }
         return Optional.of(Collections.unmodifiableMap(values));
     }
 
+    /**
+     * Whether the value, once percent-decoded, is a dot segment or contains 
one between {@code /} or {@code \}
+     * separators, for example {@code ..}, {@code %2e%2E} or {@code 
..%2F..%2Fetc%2Fpasswd}.

Review Comment:
   Done in dc4234534a9b, with the same rule: each segment counts only up to its 
first `;`. I kept the existing single pass over the decoded value instead of 
splitting each segment. A `;` position is tracked per segment, so `..;x`, `.;x` 
and `%2e%2e%3b` are refused, while `a;b` and `42;..` still match. 
`rejectsDotSegmentsFollowedByPathParameters` and 
`keepsValuesWithPathParametersThatAreNotDotSegments` cover both cases.
   
   _Claude Code on behalf of Federico Mariani_



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