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


##########
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:
   ⚠️ **Dot-segment check incomplete for `;` path parameters** — `..;foo` 
splits on `/`/`\` as a single segment and passes the check, but HTTP servers 
like Tomcat/Spring strip path parameters, leaving a bare `..`. The `/..;/` 
bypass is well-known. Fix: treat the portion before the first `;` as the 
effective segment value:
   ```suggestion
           // Treat path parameters (;param) as non-segment characters — strip 
before checking
           String effectiveSegment = segment.split(";", 2)[0];
           return effectiveSegment.equals(".") || effectiveSegment.equals("..");
   ```



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