Skip to content

Commit 425d6e0

Browse files
committed
perf: 校检文件名是否包含特殊字符
1 parent 564d470 commit 425d6e0

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

ruoyi-fastapi-frontend/src/components/FileUpload/index.vue

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,10 +104,15 @@ function handleBeforeUpload(file) {
104104
const fileExt = fileName[fileName.length - 1];
105105
const isTypeOk = props.fileType.indexOf(fileExt) >= 0;
106106
if (!isTypeOk) {
107-
proxy.$modal.msgError(`文件格式不正确, 请上传${props.fileType.join("/")}格式文件!`);
107+
proxy.$modal.msgError(`文件格式不正确请上传${props.fileType.join("/")}格式文件!`);
108108
return false;
109109
}
110110
}
111+
// 校检文件名是否包含特殊字符
112+
if (file.name.includes(',')) {
113+
proxy.$modal.msgError('文件名不正确,不能包含英文逗号!');
114+
return false;
115+
}
111116
// 校检文件大小
112117
if (props.fileSize) {
113118
const isLt = file.size / 1024 / 1024 < props.fileSize;

ruoyi-fastapi-frontend/src/components/ImageUpload/index.vue

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,9 +125,11 @@ function handleBeforeUpload(file) {
125125
isImg = file.type.indexOf("image") > -1;
126126
}
127127
if (!isImg) {
128-
proxy.$modal.msgError(
129-
`文件格式不正确, 请上传${props.fileType.join("/")}图片格式文件!`
130-
);
128+
proxy.$modal.msgError(`文件格式不正确,请上传${props.fileType.join("/")}图片格式文件!`);
129+
return false;
130+
}
131+
if (file.name.includes(',')) {
132+
proxy.$modal.msgError('文件名不正确,不能包含英文逗号!');
131133
return false;
132134
}
133135
if (props.fileSize) {

0 commit comments

Comments
 (0)