Skip to content

Commit 2d29c39

Browse files
committed
perf: 校检文件名是否包含特殊字符
1 parent 5e845d4 commit 2d29c39

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,10 +119,15 @@ export default {
119119
const fileExt = fileName[fileName.length - 1];
120120
const isTypeOk = this.fileType.indexOf(fileExt) >= 0;
121121
if (!isTypeOk) {
122-
this.$modal.msgError(`文件格式不正确, 请上传${this.fileType.join("/")}格式文件!`);
122+
this.$modal.msgError(`文件格式不正确请上传${this.fileType.join("/")}格式文件!`);
123123
return false;
124124
}
125125
}
126+
// 校检文件名是否包含特殊字符
127+
if (file.name.includes(',')) {
128+
this.$modal.msgError('文件名不正确,不能包含英文逗号!');
129+
return false;
130+
}
126131
// 校检文件大小
127132
if (this.fileSize) {
128133
const isLt = file.size / 1024 / 1024 < this.fileSize;

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,11 @@ export default {
136136
}
137137
138138
if (!isImg) {
139-
this.$modal.msgError(`文件格式不正确, 请上传${this.fileType.join("/")}图片格式文件!`);
139+
this.$modal.msgError(`文件格式不正确,请上传${this.fileType.join("/")}图片格式文件!`);
140+
return false;
141+
}
142+
if (file.name.includes(',')) {
143+
this.$modal.msgError('文件名不正确,不能包含英文逗号!');
140144
return false;
141145
}
142146
if (this.fileSize) {

0 commit comments

Comments
 (0)