fix(测试跟踪): 导入xmind 增加校验保护

This commit is contained in:
fit2-zhao 2020-09-17 11:35:59 +08:00
parent 4d983fd071
commit 252e52d316
2 changed files with 4 additions and 1 deletions
backend/src/main/java/io/metersphere

View File

@ -255,7 +255,7 @@ public class TestCaseService {
String processLog = new XmindToTestCaseParser(this, userId, projectId, testCaseNames).importXmind(multipartFile);
if (!StringUtils.isEmpty(processLog)) {
excelResponse.setSuccess(false);
ExcelErrData excelErrData = new ExcelErrData(null, 1, processLog);
ExcelErrData excelErrData = new ExcelErrData(null, 1, Translator.get("upload_fail")+""+ processLog);
errList.add(excelErrData);
excelResponse.setErrList(errList);
} else {

View File

@ -222,7 +222,10 @@ public class XmindToTestCaseParser {
StringBuffer processBuffer = new StringBuffer();
try {
File file = multipartFileToFile(multipartFile);
if (file == null || !file.exists())
return Translator.get("incorrect_format");
JsonRootBean root = XmindParser.parseObject(file);
file.delete();
if (root != null && root.getRootTopic() != null && root.getRootTopic().getChildren() != null) {
// 判断是模块还是用例
root.getRootTopic().getChildren().getAttached().forEach(item -> {