From: Dmitry Volyntsev Date: Mon, 27 Aug 2018 13:37:42 +0000 (+0300) Subject: Respecting writable attribute for property handlers. X-Git-Tag: 0.2.4~19 X-Git-Url: http://www.kaiwu.me/postgresql/commit/?a=commitdiff_plain;h=29d46bd0f31bd70b159034a382476b6c3bef065d;p=njs.git Respecting writable attribute for property handlers. --- diff --git a/njs/njs_vm.c b/njs/njs_vm.c index 60ccacb3..7ca11110 100644 --- a/njs/njs_vm.c +++ b/njs/njs_vm.c @@ -656,7 +656,7 @@ njs_vmcode_property_set(njs_vm_t *vm, njs_value_t *object, 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 --git a/njs/test/njs_unit_test.c b/njs/test/njs_unit_test.c index 51d85632..110ac750 100644 --- a/njs/test/njs_unit_test.c +++ b/njs/test/njs_unit_test.c @@ -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") },