[njs] Respecting writable attribute for property handlers.
Dmitry Volyntsev
xeioex at nginx.com
Mon Aug 27 13:55:47 UTC 2018
details: http://hg.nginx.org/njs/rev/ff2007772ec6
branches:
changeset: 588:ff2007772ec6
user: Dmitry Volyntsev <xeioex at nginx.com>
date: Mon Aug 27 16:37:42 2018 +0300
description:
Respecting writable attribute for property handlers.
diffstat:
njs/njs_vm.c | 2 +-
njs/test/njs_unit_test.c | 5 +----
2 files changed, 2 insertions(+), 5 deletions(-)
diffs (27 lines):
diff -r 76cee25a8228 -r ff2007772ec6 njs/njs_vm.c
--- a/njs/njs_vm.c Mon Aug 27 16:37:35 2018 +0300
+++ b/njs/njs_vm.c Mon Aug 27 16:37:42 2018 +0300
@@ -656,7 +656,7 @@ njs_vmcode_property_set(njs_vm_t *vm, nj
case NXT_OK:
prop = pq.lhq.value;
- if (prop->type == NJS_PROPERTY_HANDLER) {
+ if (prop->type == NJS_PROPERTY_HANDLER && prop->writable) {
ret = prop->value.data.u.prop_handler(vm, object, value,
&vm->retval);
if (nxt_slow_path(ret != NXT_OK)) {
diff -r 76cee25a8228 -r ff2007772ec6 njs/test/njs_unit_test.c
--- a/njs/test/njs_unit_test.c Mon Aug 27 16:37:35 2018 +0300
+++ b/njs/test/njs_unit_test.c Mon Aug 27 16:37:42 2018 +0300
@@ -6065,10 +6065,7 @@ static njs_unit_test_t njs_test[] =
nxt_string("true") },
{ nxt_string("({}).__proto__ = 1"),
- nxt_string("1") },
-
- { nxt_string("var o = {}; o.__proto__ = 1; o.__proto__"),
- nxt_string("[object Object]") },
+ nxt_string("TypeError: Cannot assign to read-only property '__proto__' of object") },
{ nxt_string("({}).__proto__.constructor === Object"),
nxt_string("true") },
More information about the nginx-devel
mailing list