WANG 6 년 전
부모
커밋
3e271108e1

+ 9 - 0
examcloud-exchange-outer-service/src/main/java/cn/com/qmth/examcloud/exchange/outer/service/impl/FaceServiceImpl.java

@@ -17,6 +17,7 @@ import org.apache.http.util.EntityUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
+import org.springframework.util.StringUtils;
 
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONArray;
@@ -76,6 +77,14 @@ public class FaceServiceImpl implements FaceService {
 	@Override
 	public void processFace(Long rootOrgId, String fileName, File file, String operator) {
 
+		if (StringUtils.containsWhitespace(fileName)) {
+			throw new StatusException("EX-600100", "文件名不能含有空白字符");
+		}
+
+		if (!fileName.matches("[^\\.]+\\.[^\\.]+")) {
+			throw new StatusException("EX-600101", "文件名不合法");
+		}
+
 		String identityNumber = fileName.substring(0, fileName.lastIndexOf("."));
 		String fileSuffix = fileName.substring(fileName.lastIndexOf("."));
 		String randomFileName = System.currentTimeMillis() + fileSuffix;