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


##########
components/camel-kamelet/src/main/java/org/apache/camel/component/kamelet/KameletComponent.java:
##########
@@ -132,6 +134,18 @@ protected Endpoint createEndpoint(String uri, String 
remaining, Map<String, Obje
         parameters.remove(PARAM_LOCATION);
         parameters.remove(PARAM_UUID);
 
+        // URL-decode non-RAW parameter values. The YAML DSL URL-encodes 
property values
+        // when building query strings (via URISupport.createQueryString), but 
useRawUri=true
+        // prevents automatic decoding during URI parsing. Decode here so 
values like
+        // "application/json" are not left as "application%2Fjson".
+        for (Map.Entry<String, Object> entry : parameters.entrySet()) {
+            if (entry.getValue() instanceof String s
+                    && !s.startsWith(URISupport.RAW_TOKEN_PREFIX + "(")
+                    && !s.startsWith(URISupport.RAW_TOKEN_PREFIX + "{")) {
+                entry.setValue(URLDecoder.decode(s, StandardCharsets.UTF_8));

Review Comment:
   `createEndpoint()` is called from all DSLs (Java, XML, YAML), not just YAML. 
If a value arrives without URL-encoding (e.g., from Java DSL 
`to("kamelet:foo?contentType=application/json")`), `URLDecoder.decode()` will 
still process it. While `application/json` survives decoding, a value 
containing `%` (like `100%done`) would be corrupted or throw an 
`IllegalArgumentException`.
   
   Consider either:
   - Fixing the encoding at the source (the YAML DSL's 
`URISupport.createQueryString()` call) so values aren't double-encoded
   - Or guarding this decode with a check that the value actually contains 
URL-encoded sequences (e.g., `%xx` patterns)



##########
core/camel-base/src/main/java/org/apache/camel/component/properties/DefaultPropertiesParser.java:
##########
@@ -514,7 +514,7 @@ private String doGetPropertyValue(String key, String 
defaultValue) {
             if (answer == null) {
                 answer = value;
             }
-            return answer;
+            return answer != null ? answer.trim() : null;

Review Comment:
   This `.trim()` applies to **every** property resolution across the entire 
framework, not just YAML/kamelet scenarios. Property values that legitimately 
contain leading/trailing whitespace (passwords with trailing spaces, PEM data, 
regex patterns) would be silently corrupted.
   
   The root cause is YAML literal block scalars (`|`) preserving trailing 
newlines. This should be fixed at the YAML parsing layer where the newline is 
introduced, not in the global properties parser.
   
   Consider removing this change and instead trimming at the YAML DSL level 
where property values are extracted from block scalars.



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