Skip to content

Commit

Permalink
fix: 配置文件路径限制优化 (#3500)
Browse files Browse the repository at this point in the history
  • Loading branch information
Yuikill committed Sep 9, 2024
1 parent 0dbd2d2 commit 52028e6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -228,33 +228,7 @@
// 配置文件绝对路径校验规则,path+filename
fileAP: [
{
validator: (val: string) => {
// 必须为绝对路径, 且不能以/结尾
if (!val.startsWith('/') || val.endsWith('/')) {
return false;
}
const parts = val.split('/').slice(1);
const fileName = parts.pop() as string;
// 文件名称校验
// 文件名和路径不能全由.组成
if (!/^((?!\.{1,}$)[\u4e00-\u9fa5A-Za-z0-9.\-_#%,:?!@$^+=\\[\]{}]+)$/.test(fileName)) {
return false;
}
let isValid = true;
// 文件路径校验
parts.some((part) => {
if (!/^((?!\.{1,}$)[\u4e00-\u9fa5A-Za-z0-9.\-_#%,:?!@$^+=\\[\]{}]+)$/.test(part)) {
isValid = false;
return true;
}
return false;
});
return isValid;
},
validator: (val: string) => /^\/(?:[^/]+\/)*[^/]+$/.test(val),
message: t('无效的路径,路径不符合Unix文件路径格式规范'),
trigger: 'change',
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -582,6 +582,11 @@
});
configsCount.value = res.count;
conflictCount.value = res.conflict_number || 0;
if (conflictCount.value === 0) {
configStore.$patch((state) => {
state.onlyViewConflict = false;
});
}
} catch (e) {
console.error(e);
} finally {
Expand Down

0 comments on commit 52028e6

Please sign in to comment.