Commit b75fd821 authored by tianbo's avatar tianbo

fix(amos-boot-module-jg-biz): 修复 Word 模板中的控制字符问题

- 在 convertContent 方法中添加 removeControlCharsManual 函数调用 - 新增 removeControlCharsManual 方法,手动移除控制字符 - 保留了换行符、回车符和制表符
parent 0dd3e344
......@@ -287,6 +287,7 @@ public class WordTemplateUtils {
if (value == null) {
return null;
}
value = removeControlCharsManual(value);
return value.replace("&", "&")
.replace("<", "&lt;")
.replace(">", "&gt;")
......@@ -296,4 +297,18 @@ public class WordTemplateUtils {
.replace(")", "&#41;");
}
public static String removeControlCharsManual(String input) {
if (input == null) return "";
StringBuilder sb = new StringBuilder();
for (int i = 0; i < input.length(); i++) {
char c = input.charAt(i);
// 只保留允许的字符
if (c > 31 || c == '\t' || c == '\n' || c == '\r') {
sb.append(c);
}
}
return sb.toString();
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment