Fix code scanning alert no. 2: Prototype-polluting assignment

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
This commit is contained in:
alexpolo1
2024-10-20 10:59:14 +02:00
committed by GitHub
parent e9d3f6bace
commit b561d43aaf

View File

@@ -12,10 +12,18 @@ const encoder = new TextEncoder();
self.addEventListener("message", async function (event) {
if (event.data.close) {
let connectionID = event.data.close;
if (connectionID === '__proto__' || connectionID === 'constructor' || connectionID === 'prototype') {
console.error("Invalid connectionID");
return;
}
delete connections[connectionID];
return;
} else if (event.data.getMore) {
let connectionID = event.data.getMore;
if (connectionID === '__proto__' || connectionID === 'constructor' || connectionID === 'prototype') {
console.error("Invalid connectionID");
return;
}
let { curOffset, value, reader, intBuffer, byteBuffer } =
connections[connectionID];
// if we still have some in buffer, then just send it back straight away