mirror of
https://github.com/thepeacockproject/Peacock
synced 2024-11-22 22:12:45 +01:00
[Security] Intentionally remove prototypes from objects being cloned
Signed-off-by: Reece Dunham <me@rdil.rocks>
This commit is contained in:
parent
b4bb032c99
commit
34789f8ff2
@ -346,20 +346,15 @@ export function fastClone<T>(item: T): T {
|
||||
result[index] = fastClone(child)
|
||||
})
|
||||
} else if (typeof item === "object") {
|
||||
// @ts-expect-error JavaScript built-in things.
|
||||
if (!item.prototype) {
|
||||
// this is a literal
|
||||
if (item instanceof Date) {
|
||||
result = new Date(item)
|
||||
} else {
|
||||
// object literal
|
||||
result = {}
|
||||
for (const i in item) {
|
||||
result[i] = fastClone(item[i])
|
||||
}
|
||||
}
|
||||
// this is a literal
|
||||
if (item instanceof Date) {
|
||||
result = new Date(item)
|
||||
} else {
|
||||
result = item
|
||||
// object literal
|
||||
result = {}
|
||||
for (const i in item) {
|
||||
result[i] = fastClone(item[i])
|
||||
}
|
||||
}
|
||||
} else {
|
||||
result = item
|
||||
|
Loading…
Reference in New Issue
Block a user