yuxiqian commented on code in PR #4261:
URL: https://github.com/apache/flink-cdc/pull/4261#discussion_r2772135771
##########
flink-cdc-runtime/src/main/java/org/apache/flink/cdc/runtime/parser/JaninoCompiler.java:
##########
@@ -174,7 +174,10 @@ private static Java.Rvalue translateSqlSqlLiteral(Context
context, SqlLiteral sq
Object value = sqlLiteral.getValue();
if (sqlLiteral instanceof SqlCharStringLiteral) {
// Double quotation marks represent strings in Janino.
- value = "\"" + sqlLiteral.getValueAs(NlsString.class).getValue() +
"\"";
+ // Escape backslashes first, then double quotes for proper Janino
string literals.
+ String stringValue =
sqlLiteral.getValueAs(NlsString.class).getValue();
+ stringValue = stringValue.replace("\\", "\\\\").replace("\"",
"\\\"");
+ value = "\"" + stringValue + "\"";
Review Comment:
Nice catch! I confirmed the implementation is the same as Apache common's
`StringEscapeUtils#escapeJava`.
<img width="1097" height="125" alt="Image"
src="https://github.com/user-attachments/assets/86cb20c9-4c53-46b3-b4d5-f6b87174e132"
/>
--
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]