fix(测试跟踪): 导入标签反斜杠字符转义问题

--bug=1017858 --user=宋昌昌 【测试跟踪】github#18427,功能用例模板,标签列带\,导入后编辑功能用例,用例名称和所属模块不显示 https://www.tapd.cn/55049933/s/1265049

Co-authored-by: song-cc-rock <changchang.song@fit2cloud.com>
This commit is contained in:
MeterSphere Bot 2022-10-19 10:31:45 +08:00 committed by GitHub
parent d60ffba0cb
commit 2e149c411c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 2 deletions

View File

@ -649,8 +649,10 @@ public class TestCaseNoModelDataListener extends AnalysisEventListener<Map<Integ
return "[]";
} catch (Exception e) {
if (tags != null) {
Stream<String> stringStream = Arrays.stream(tags.split("[,;\"\\r|\\n|\\r\\n\"]")); //当标签值以中英文的逗号和分号分隔时才能正确解析
List<String> tagList = stringStream.map(tag -> tag = "\"" + tag + "\"")
//当标签值以中英文的逗号和分号分隔时才能正确解析
Stream<String> stringStream = Arrays.stream(tags.split("[,;\"\\r|\\n|\\r\\n\"]"));
//替换非法字符反斜杠"\""\\"
List<String> tagList = stringStream.map(tag -> tag = "\"" + tag.replaceAll("\\\\", "\\\\\\\\") + "\"")
.collect(Collectors.toList());
String modifiedTags = StringUtils.join(tagList, ",");
modifiedTags = "[" + modifiedTags + "]";