commit
This commit is contained in:
@@ -101,26 +101,28 @@
|
||||
<script src="https://map.qq.com/api/gljs?v=2.exp&key=MLLBZ-GQECI-ASXG7-5GNOZ-XW2OF-H5BVH"></script>
|
||||
|
||||
<script>
|
||||
// 安全地冻结 Object.prototype(跳过不可配置属性)
|
||||
(function () {
|
||||
const badKeys = ['constructor', 'prototype'];
|
||||
for (const key of badKeys) {
|
||||
if (key in Object.prototype) {
|
||||
try {
|
||||
delete Object.prototype[key];
|
||||
} catch (e) {
|
||||
// 忽略无法删除的属性(如 __proto__ 在现代浏览器中不可删除)
|
||||
}
|
||||
}
|
||||
}
|
||||
// 在加载 lodash 后、使用前插入
|
||||
const originalDefaultsDeep = window._.defaultsDeep;
|
||||
window._.defaultsDeep = function(...args) {
|
||||
// 先对所有参数做原型污染清洗
|
||||
const cleanArgs = args.map(arg => sanitizeForPrototypePollution(arg));
|
||||
return originalDefaultsDeep.apply(window._, cleanArgs);
|
||||
};
|
||||
|
||||
// 冻结 Object.prototype(如果可能)
|
||||
try {
|
||||
Object.freeze(Object.prototype);
|
||||
} catch (e) {
|
||||
// 忽略错误(某些环境可能不允许)
|
||||
function sanitizeForPrototypePollution(obj) {
|
||||
if (obj === null || typeof obj !== 'object') return obj;
|
||||
if (Array.isArray(obj)) return obj.map(sanitizeForPrototypePollution);
|
||||
|
||||
const clean = {};
|
||||
for (const key in obj) {
|
||||
if (!Object.hasOwn(obj, key)) continue;
|
||||
if (key === '__proto__' || key === 'constructor' || key === 'prototype') {
|
||||
continue;
|
||||
}
|
||||
clean[key] = sanitizeForPrototypePollution(obj[key]);
|
||||
}
|
||||
})();
|
||||
return clean;
|
||||
}
|
||||
</script>
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
@@ -100,26 +100,28 @@
|
||||
<!-- import jsencrypt-->
|
||||
<script src="${base!}/assets/platform/plugins/jsencrypt/jsencrypt.min.js"></script>
|
||||
<script>
|
||||
// 安全地冻结 Object.prototype(跳过不可配置属性)
|
||||
(function () {
|
||||
const badKeys = ['constructor', 'prototype'];
|
||||
for (const key of badKeys) {
|
||||
if (key in Object.prototype) {
|
||||
try {
|
||||
delete Object.prototype[key];
|
||||
} catch (e) {
|
||||
// 忽略无法删除的属性(如 __proto__ 在现代浏览器中不可删除)
|
||||
}
|
||||
}
|
||||
}
|
||||
// 在加载 lodash 后、使用前插入
|
||||
const originalDefaultsDeep = window._.defaultsDeep;
|
||||
window._.defaultsDeep = function(...args) {
|
||||
// 先对所有参数做原型污染清洗
|
||||
const cleanArgs = args.map(arg => sanitizeForPrototypePollution(arg));
|
||||
return originalDefaultsDeep.apply(window._, cleanArgs);
|
||||
};
|
||||
|
||||
// 冻结 Object.prototype(如果可能)
|
||||
try {
|
||||
Object.freeze(Object.prototype);
|
||||
} catch (e) {
|
||||
// 忽略错误(某些环境可能不允许)
|
||||
function sanitizeForPrototypePollution(obj) {
|
||||
if (obj === null || typeof obj !== 'object') return obj;
|
||||
if (Array.isArray(obj)) return obj.map(sanitizeForPrototypePollution);
|
||||
|
||||
const clean = {};
|
||||
for (const key in obj) {
|
||||
if (!Object.hasOwn(obj, key)) continue;
|
||||
if (key === '__proto__' || key === 'constructor' || key === 'prototype') {
|
||||
continue;
|
||||
}
|
||||
clean[key] = sanitizeForPrototypePollution(obj[key]);
|
||||
}
|
||||
})();
|
||||
return clean;
|
||||
}
|
||||
</script>
|
||||
<script>
|
||||
new Vue({
|
||||
|
||||
Reference in New Issue
Block a user