Bug 446026 - restore utility of eval(s, o). r=mrbkap
This commit is contained in:
@@ -1233,12 +1233,11 @@ obj_eval(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
if (caller && !caller->varobj && !js_GetCallObject(cx, caller, NULL))
|
||||
return JS_FALSE;
|
||||
|
||||
/* eval no longer takes an optional trailing argument. */
|
||||
if (argc >= 2 &&
|
||||
!JS_ReportErrorFlagsAndNumber(cx, JSREPORT_WARNING | JSREPORT_STRICT,
|
||||
js_GetErrorMessage, NULL,
|
||||
JSMSG_EVAL_ARITY)) {
|
||||
return JS_FALSE;
|
||||
/* Accept an optional trailing argument that overrides the scope object. */
|
||||
if (argc >= 2) {
|
||||
if (!js_ValueToObject(cx, argv[1], &scopeobj))
|
||||
return JS_FALSE;
|
||||
argv[1] = OBJECT_TO_JSVAL(scopeobj);
|
||||
}
|
||||
|
||||
/* From here on, control must exit through label out with ok set. */
|
||||
@@ -1299,6 +1298,19 @@ obj_eval(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
ok = js_CheckPrincipalsAccess(cx, scopeobj,
|
||||
JS_StackFramePrincipals(cx, caller),
|
||||
cx->runtime->atomState.evalAtom);
|
||||
if (!ok)
|
||||
goto out;
|
||||
|
||||
scopeobj = js_NewWithObject(cx, scopeobj,
|
||||
JS_GetGlobalForObject(cx, scopeobj), -1);
|
||||
if (!scopeobj) {
|
||||
ok = JS_FALSE;
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
|
||||
/* Ensure we compile this eval with the right object in the scope chain. */
|
||||
|
||||
Reference in New Issue
Block a user