gnodet-bot commented on code in PR #27535:
URL: https://github.com/apache/camel/pull/27535#discussion_r4222038222
##########
components/camel-dataweave/src/main/java/org/apache/camel/component/dataweave/DataWeaveConverter.java:
##########
@@ -214,8 +225,24 @@ private String emitNode(DataWeaveAst node) {
}
private String emitStringLit(StringLit s) {
- // The lexer preserves escape sequences as-is, so don't double-escape
- return "\"" + s.value().replace("\"", "\\\"") + "\"";
+ String value = s.value();
+ // Jsonnet has no in-string interpolation. DataWeave uses "Hello
$(expr)" but there is
+ // no faithful automated conversion (the sub-expression must be
re-emitted through the AST).
+ // Emit as a TODO comment and a placeholder so the converter output is
syntactically valid.
+ if (value.contains("$(")) {
+ todoCount++;
+ String escapedInterp = value.replaceAll("(?<!\\\\)\"", "\\\\\"");
+ return includeComments
+ ? "/* TODO: manual conversion needed -- string
interpolation: \"" + value + "\"*/\n\""
+ + escapedInterp + "\""
Review Comment:
🐛 **Nit — block-comment injection:** `value` is concatenated raw into a `/*
… */` comment. If the DataWeave string contains `*/` the generated Jsonnet
comment closes early, producing malformed output. Consider sanitizing before
embedding:
```suggestion
? "/* TODO: manual conversion needed -- string
interpolation: \"" + value.replace("*/", "* /") + "\"*/\n\""
+ escapedInterp + "\""
: "\"" + escapedInterp + "\"";
```
--
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]