1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-11-27 16:10:57 -05:00

fix(ext): Add checks for owning properties in for-in loops (#17139)

In the for-in loops, there were a few places where we forgot to check if
objects owned some properties, so I added them.
This commit is contained in:
Kenta Moriuchi 2022-12-22 10:54:38 +09:00 committed by Bartek Iwańczuk
parent ee39fb2f27
commit b1cee59fcb
No known key found for this signature in database
GPG key ID: 0C6BCDDC3B3AD750
3 changed files with 11 additions and 1 deletions

View file

@ -29,6 +29,7 @@
JSONStringify, JSONStringify,
MathCeil, MathCeil,
ObjectAssign, ObjectAssign,
ObjectPrototypeHasOwnProperty,
ObjectPrototypeIsPrototypeOf, ObjectPrototypeIsPrototypeOf,
StringPrototypeToLowerCase, StringPrototypeToLowerCase,
StringPrototypeToUpperCase, StringPrototypeToUpperCase,
@ -211,6 +212,9 @@
// 5. // 5.
let desiredType = undefined; let desiredType = undefined;
for (const key in registeredAlgorithms) { for (const key in registeredAlgorithms) {
if (!ObjectPrototypeHasOwnProperty(registeredAlgorithms, key)) {
continue;
}
if ( if (
StringPrototypeToUpperCase(key) === StringPrototypeToUpperCase(algName) StringPrototypeToUpperCase(key) === StringPrototypeToUpperCase(algName)
) { ) {
@ -242,6 +246,9 @@
const dict = simpleAlgorithmDictionaries[desiredType]; const dict = simpleAlgorithmDictionaries[desiredType];
// 10. // 10.
for (const member in dict) { for (const member in dict) {
if (!ObjectPrototypeHasOwnProperty(dict, member)) {
continue;
}
const idlType = dict[member]; const idlType = dict[member];
const idlValue = normalizedAlgorithm[member]; const idlValue = normalizedAlgorithm[member];
// 3. // 3.

View file

@ -231,7 +231,7 @@
transferredArrayBuffers, transferredArrayBuffers,
}); });
for (const i in arrayBufferIdsInTransferables) { for (let i = 0; i < arrayBufferIdsInTransferables.length; ++i) {
const id = arrayBufferIdsInTransferables[i]; const id = arrayBufferIdsInTransferables[i];
transferables[id] = transferredArrayBuffers[i]; transferables[id] = transferredArrayBuffers[i];
} }

View file

@ -1013,6 +1013,9 @@
function configurePrototype(prototype) { function configurePrototype(prototype) {
const descriptors = ObjectGetOwnPropertyDescriptors(prototype.prototype); const descriptors = ObjectGetOwnPropertyDescriptors(prototype.prototype);
for (const key in descriptors) { for (const key in descriptors) {
if (!ObjectPrototypeHasOwnProperty(descriptors, key)) {
continue;
}
if (key === "constructor") continue; if (key === "constructor") continue;
const descriptor = descriptors[key]; const descriptor = descriptors[key];
if ( if (