gnodet commented on code in PR #23391:
URL: https://github.com/apache/camel/pull/23391#discussion_r3287575080
##########
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
Camel framework -- system properties, environment variables, `.properties`
files, Spring Boot config, etc. Property values that legitimately contain
trailing whitespace (passwords, PEM data, regex, template strings) would be
silently corrupted.
The root cause is YAML literal block scalars (`|`) preserving trailing
newlines. Please fix this at the YAML parsing layer where property values are
extracted, not in the global properties parser.
Suggest removing this change entirely.
_Claude Code on behalf of Guillaume Nodet_
##########
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:
`URLDecoder.decode()` will throw `IllegalArgumentException` on values
containing bare `%` characters (e.g., `100%complete` or `[a-z]%[0-9]`). This
`createEndpoint()` method is called from all DSLs, not just YAML, so
non-encoded values will reach here.
Consider either:
1. **Fix at the source**: use `createQueryString(params, false)` in
`YamlRoutesBuilderLoader` for kamelet URIs (like `KameletDeserializer` and
`YamlSupport` already do with `encode=false`). This would be consistent with
the CAMEL-23284 approach.
2. **Or guard the decode**: at minimum wrap in try/catch
`IllegalArgumentException` and fall back to the original value.
```suggestion
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 + "{")) {
try {
entry.setValue(URLDecoder.decode(s,
StandardCharsets.UTF_8));
} catch (IllegalArgumentException e) {
// value contains bare % not part of URL encoding, leave
as-is
}
}
}
```
Though option 1 (fixing the encoding at the YAML DSL source) would be the
cleanest solution.
_Claude Code on behalf of Guillaume Nodet_
--
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]