修改跨站脚本攻击缺陷

This commit is contained in:
范强强
2024-03-19 17:43:13 +08:00
parent f1ab8f1db2
commit 704692fb3e
791 changed files with 52 additions and 272365 deletions
@@ -117,6 +117,19 @@
onlineImage = onlineImage || new OnlineImage('imageList');
}
function htmlspecialchars (string) {
var entityMap = {
'&': '&',
'<': '&lt;',
'>': '&gt;',
'"': '&quot;',
"'": '&#39;',
'/': '&#x2F;'
}
return String(string).replace(/[&<>"'\/]/g, function (s) {
return entityMap[s]
})
}
/* 更新背景色设置面板 */
function updateFormState (radio, color, url, align, x, y) {
var nocolorRadio = $G('nocolorRadio'),
@@ -132,7 +145,8 @@
if(url && /^\//.test(url)) {
var a = document.createElement('a');
a.href = url;
a.href = htmlspecialchars(url);
a.ref= 'nofollow noopener noreferrer'
browser.ie && (a.href = a.href);
url = browser.ie ? a.href:(a.protocol + '//' + a.host + a.pathname + a.search + a.hash);
}