修改跨站脚本攻击缺陷

This commit is contained in:
范强强
2024-03-20 10:28:46 +08:00
parent 1e2d2b9a9b
commit df9298aac3
2 changed files with 12 additions and 4 deletions
@@ -144,9 +144,13 @@
} }
if(url && /^\//.test(url)) { if(url && /^\//.test(url)) {
var a = document.createElement('a'); var a = document.createElement('a');
a.href = htmlspecialchars(url); const index = url.indexOf('?')
a.ref= 'nofollow noopener noreferrer' const searchLeft = url.slice(0, index)
const searchRight = url.slice(index + 1, url.length)
url = searchLeft + htmlspecialchars(searchRight)
a.href = url;
a.rel= 'nofollow noopener noreferrer'
browser.ie && (a.href = a.href); browser.ie && (a.href = a.href);
url = browser.ie ? a.href:(a.protocol + '//' + a.host + a.pathname + a.search + a.hash); url = browser.ie ? a.href:(a.protocol + '//' + a.host + a.pathname + a.search + a.hash);
} }
@@ -288,7 +288,11 @@ export const ConfigurableTableMixin = {
// this.$message.success(`${info.file.name} 文件上传成功`); // this.$message.success(`${info.file.name} 文件上传成功`);
if (info.file.response.code === 201) { if (info.file.response.code === 201) {
const { message, result: { msg, fileUrl, fileName } } = info.file.response const { message, result: { msg, fileUrl, fileName } } = info.file.response
const href = this.htmlspecialchars(window._CONFIG.domianURL + fileUrl) let href = window._CONFIG.domianURL + fileUrl
const index = href.indexOf('?')
const searchLeft = href.slice(0, index)
const searchRight = href.slice(index + 1, href.length)
href = searchLeft + this.htmlspecialchars(searchRight)
this.$warning({ this.$warning({
title: message, title: message,
content: ( content: (