DanYanShuYv4j opened a new issue, #18217:
URL: https://github.com/apache/dolphinscheduler/issues/18217

   ### Search before asking
   
   - [x] I had searched in the 
[issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and 
found no similar issues.
   
   
   ### What happened
   
   DolphinScheduler DataX 任务插件在生成 Shell 命令时,对包含单引号的变量值没有做转义处理,导致 Shell 
解析时引号错乱,10:59:09 被当成 Java 主类名执行。
   这是
   
   
[1778036486909.log](https://github.com/user-attachments/files/27426592/1778036486909.log)
   
   'AND create_data > '2026-05-06 10:59:09''
   
   
   ### What you expected to happen
   
   `src/main/java/org/apache/dolphinscheduler/plugin/task/datax/DataxTask.java
   该类的添加参数方法没有对引号转译
   `
   ```java
   private StringBuilder addCustomParameters(Map<String, Property> paramsMap) {
           if (paramsMap == null || paramsMap.size() == 0) {
               return new StringBuilder();
           }
           StringBuilder customParameters = new StringBuilder("-p \"");
           for (Map.Entry<String, Property> entry : paramsMap.entrySet()) {
               customParameters.append(String.format(CUSTOM_PARAM, 
entry.getKey(), entry.getValue().getValue()));
           }
           customParameters.replace(4, 5, "");
           customParameters.append("\"");
           return customParameters;
       }
   ```
   
   改为下方代码,增加转译即可
   ```java
   private StringBuilder addCustomParameters(Map<String, Property> paramsMap) {
           if (paramsMap == null || paramsMap.size() == 0) {
               return new StringBuilder();
           }
           StringBuilder customParameters = new StringBuilder("-p \"");
           for (Map.Entry<String, Property> entry : paramsMap.entrySet()) {
               String value = entry.getValue().getValue();
               // Escape single quotes for shell safety: ' -> '\'' (bash 
standard escape)
               // Prevents shell quoting conflicts when value contains single 
quotes, e.g.
               // "AND create_data > '2026-05-06 10:59:09'" -> "AND create_data 
> '\''2026-05-06 10:59:09'\''"
               String escapedValue = value.replace("'", "'\\''");
               customParameters.append(String.format(CUSTOM_PARAM, 
entry.getKey(), escapedValue));
           }
           customParameters.replace(4, 5, "");
           customParameters.append("\"");
           return customParameters;
       }
   ```
   
   
   ### How to reproduce
   
   ```java
     → 生成 ds_incr_condition = "AND create_data > '2026-05-06 10:59:09'"(含单引号)
       → DolphinScheduler varPool 传递
         → DS DataX 插件生成 Shell 命令时单引号嵌套冲突 ← 失败点
           → JVM 收到错误参数
   ```
   
   ### Anything else
   
   _No response_
   
   ### Version
   
   3.4.0
   
   ### Are you willing to submit PR?
   
   - [x] Yes I am willing to submit a PR!
   
   ### Code of Conduct
   
   - [x] I agree to follow this project's [Code of 
Conduct](https://www.apache.org/foundation/policies/conduct)
   


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