Commit bc132aba authored by 韩桐桐's avatar 韩桐桐

fix(jg):打印时添加list类型的转义处理

parent 5131349e
...@@ -20,9 +20,7 @@ import java.io.*; ...@@ -20,9 +20,7 @@ import java.io.*;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.nio.file.Files; import java.nio.file.Files;
import java.nio.file.Paths; import java.nio.file.Paths;
import java.util.HashMap; import java.util.*;
import java.util.Map;
import java.util.UUID;
@Slf4j @Slf4j
public class WordTemplateUtils { public class WordTemplateUtils {
...@@ -239,6 +237,8 @@ public class WordTemplateUtils { ...@@ -239,6 +237,8 @@ public class WordTemplateUtils {
escapedMap.put(key, escapeValue((String) value)); escapedMap.put(key, escapeValue((String) value));
} else if (value instanceof Map) { } else if (value instanceof Map) {
escapedMap.put(key, escapeSpecialCharacters((Map<String, Object>) value)); escapedMap.put(key, escapeSpecialCharacters((Map<String, Object>) value));
} else if (value instanceof List) {
escapedMap.put(key, escapeList((List<?>) value));
} else { } else {
escapedMap.put(key, value); escapedMap.put(key, value);
} }
...@@ -246,6 +246,22 @@ public class WordTemplateUtils { ...@@ -246,6 +246,22 @@ public class WordTemplateUtils {
return escapedMap; return escapedMap;
} }
private static List<Object> escapeList(List<?> inputList) {
List<Object> escapedList = new ArrayList<>();
for (Object value : inputList) {
if (value instanceof String) {
escapedList.add(escapeValue((String) value));
} else if (value instanceof Map) {
escapedList.add(escapeSpecialCharacters((Map<String, Object>) value));
} else if (value instanceof List) {
escapedList.add(escapeList((List<?>) value));
} else {
escapedList.add(value);
}
}
return escapedList;
}
private static String escapeValue(String value) { private static String escapeValue(String value) {
if (value == null) { if (value == null) {
return null; return null;
......
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