update 优化 后端导入返回信息使用\n分割 避免前端出现xss问题
This commit is contained in:
@@ -152,9 +152,7 @@ const handleRegister = () => {
|
||||
const [err] = await to(register(registerForm.value));
|
||||
if (!err) {
|
||||
const username = registerForm.value.username;
|
||||
await ElMessageBox.alert('<span style="color: red; ">' + t('register.registerSuccess', { username }) + '</font>', '系统提示', {
|
||||
app: undefined,
|
||||
dangerouslyUseHTMLString: true,
|
||||
await ElMessageBox.alert(t('register.registerSuccess', { username }), '系统提示', {
|
||||
type: 'success'
|
||||
});
|
||||
await router.push('/login');
|
||||
|
||||
@@ -596,13 +596,21 @@ const importTemplate = () => {
|
||||
const handleFileUploadProgress = () => {
|
||||
upload.isUploading = true;
|
||||
};
|
||||
|
||||
const formatImportResultMessage = (message: unknown) => {
|
||||
return String(message ?? '')
|
||||
.replace(/<br\s*\/?>/gi, '\n')
|
||||
.replace(/ /gi, ' ')
|
||||
.replace(/<[^>]+>/g, '');
|
||||
};
|
||||
|
||||
/** 文件上传成功处理 */
|
||||
const handleFileSuccess = (response: any, file: UploadFile) => {
|
||||
upload.open = false;
|
||||
upload.isUploading = false;
|
||||
uploadRef.value?.handleRemove(file);
|
||||
ElMessageBox.alert("<div style='overflow: auto;overflow-x: hidden;max-height: 70vh;padding: 10px 20px 0;'>" + response.msg + '</div>', '导入结果', {
|
||||
dangerouslyUseHTMLString: true
|
||||
ElMessageBox.alert(formatImportResultMessage(response.msg), '导入结果', {
|
||||
customClass: 'import-result-box'
|
||||
});
|
||||
getList();
|
||||
};
|
||||
@@ -708,4 +716,13 @@ async function handleDeptChange(value: number | string) {
|
||||
@use '@/assets/styles/components/page-shell' as pageShell;
|
||||
|
||||
@include pageShell.tree-table-crud-page;
|
||||
|
||||
:global(.import-result-box .el-message-box__message) {
|
||||
max-height: 70vh;
|
||||
overflow-y: auto;
|
||||
overflow-x: hidden;
|
||||
padding: 10px 20px 0;
|
||||
white-space: pre-wrap;
|
||||
word-break: break-word;
|
||||
}
|
||||
</style>
|
||||
|
||||
Reference in New Issue
Block a user