Isolate repair accessors
MODIFY
shim/src/accessors.js
shim/src/accessors.js
@@ -9,7 +9,14 @@ import {
getOwnPropertyDescriptor
} from './commons';
-import { asPropertyName } from './utilities';
+// TOCTTOU and .asString() games could enable attacker to skip some
+// intermediate ancestors, so we stringify/propify this once, first.
+export function asPropertyName(prop) {
+ if (typeof prop === 'symbol') {
+ return prop;
+ }
+ return `${prop}`;
+}
/**
* Replace the legacy accessors of Object to comply with strict mode
@@ -53,8 +60,8 @@ export function repairAccessors(unsafeRec) {
}
},
__lookupGetter__: {
- value(unfixedProp) {
- const prop = asPropertyName(unfixedProp);
+ value(prop) {
+ prop = asPropertyName(prop);
let base = this;
let desc;
while (base && !(desc = getOwnPropertyDescriptor(base, prop))) {
@@ -64,8 +71,8 @@ export function repairAccessors(unsafeRec) {
}
},
__lookupSetter__: {
- value(unfixedProp) {
- const prop = asPropertyName(unfixedProp);
+ value(prop) {
+ prop = asPropertyName(prop);
let base = this;
let desc;
while (base && !(desc = getOwnPropertyDescriptor(base, prop))) {

MODIFY
shim/src/utilities.js
shim/src/utilities.js
@@ -21,11 +21,3 @@ export function assert(condition, message) {
}
}
-// TOCTTOU and .asString() games could enable attacker to skip some
-// intermediate ancestors, so we stringify/propify this once, first.
-export function asPropertyName(s) {
- if (typeof s === 'symbol') {
- return s;
- }
- return `${s}`;
-}

Isolate repair accessors