From 1250c3679366b90b73685f6a12c8e8fb91596bfb Mon Sep 17 00:00:00 2001 From: WangXu10 Date: Tue, 15 Aug 2023 14:18:59 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E6=B5=8B=E8=AF=95=E8=B7=9F=E8=B8=AA):=20?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=AF=BC=E5=85=A5=E7=94=A8=E4=BE=8B=E5=90=8E?= =?UTF-8?q?=E6=9F=A5=E7=9C=8B=E8=AF=A6=E6=83=85=E6=8A=A5=E9=94=99=E7=BC=BA?= =?UTF-8?q?=E9=99=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --bug=1028181 --user=王旭 【测试跟踪】github#25900,【测试跟踪】标签为数字开头,且含有空格的功能用例,导入后,用例详情页面啥内容也没有。 https://www.tapd.cn/55049933/s/1403774 --- .../listener/TestCaseNoModelDataListener.java | 29 +++++++------------ 1 file changed, 10 insertions(+), 19 deletions(-) diff --git a/test-track/backend/src/main/java/io/metersphere/excel/listener/TestCaseNoModelDataListener.java b/test-track/backend/src/main/java/io/metersphere/excel/listener/TestCaseNoModelDataListener.java index bfbe497edb..9c58749d75 100644 --- a/test-track/backend/src/main/java/io/metersphere/excel/listener/TestCaseNoModelDataListener.java +++ b/test-track/backend/src/main/java/io/metersphere/excel/listener/TestCaseNoModelDataListener.java @@ -663,26 +663,17 @@ public class TestCaseNoModelDataListener extends AnalysisEventListener stringStream = Arrays.stream(tags.split("[,;,;\"\\r|\\n|\\r\\n\"]")); - //替换非法字符反斜杠"\"为"\\" - List tagList = stringStream.map(tag -> tag = "\"" + tag.replaceAll("\\\\", "\\\\\\\\") + "\"") - .collect(Collectors.toList()); - String modifiedTags = StringUtils.join(tagList, ","); - modifiedTags = "[" + modifiedTags + "]"; - return modifiedTags; - } else { - return "[]"; - } + if (StringUtils.isNotBlank(tags)) { + //当标签值以中英文的逗号和分号分隔时才能正确解析 + Stream stringStream = Arrays.stream(tags.split("[,;,;\"\\r|\\n|\\r\\n\"]")); + //替换非法字符反斜杠"\"为"\\" + List tagList = stringStream.map(tag -> tag = "\"" + tag.replaceAll("\\\\", "\\\\\\\\") + "\"") + .collect(Collectors.toList()); + String modifiedTags = StringUtils.join(tagList, ","); + modifiedTags = "[" + modifiedTags + "]"; + return modifiedTags; } + return "[]"; } /**