[njs] Fixed Object.prototype.hasOwnProperty() without arguments.

Dmitry Volyntsev xeioex at nginx.com
Tue Jun 20 16:33:26 UTC 2017


details:   http://hg.nginx.org/njs/rev/36947c6cb8c6
branches:  
changeset: 373:36947c6cb8c6
user:      Dmitry Volyntsev <xeioex at nginx.com>
date:      Tue Jun 20 18:06:19 2017 +0300
description:
Fixed Object.prototype.hasOwnProperty() without arguments.

diffstat:

 njs/njs_object.c         |  2 +-
 njs/test/njs_unit_test.c |  6 ++++++
 2 files changed, 7 insertions(+), 1 deletions(-)

diffs (28 lines):

diff -r 1c4d7281d44e -r 36947c6cb8c6 njs/njs_object.c
--- a/njs/njs_object.c	Tue Jun 20 17:12:44 2017 +0300
+++ b/njs/njs_object.c	Tue Jun 20 18:06:19 2017 +0300
@@ -1373,7 +1373,7 @@ njs_object_prototype_has_own_property(nj
 
     retval = &njs_string_false;
 
-    if (njs_is_object(&args[0])) {
+    if (nargs > 1 && njs_is_object(&args[0])) {
 
         if (njs_is_array(&args[0])) {
             array = args[0].data.u.array;
diff -r 1c4d7281d44e -r 36947c6cb8c6 njs/test/njs_unit_test.c
--- a/njs/test/njs_unit_test.c	Tue Jun 20 17:12:44 2017 +0300
+++ b/njs/test/njs_unit_test.c	Tue Jun 20 18:06:19 2017 +0300
@@ -5989,6 +5989,12 @@ static njs_unit_test_t  njs_test[] =
     { nxt_string("var o = {a:1}; o.hasOwnProperty()"),
       nxt_string("false") },
 
+    { nxt_string("[,].hasOwnProperty()"),
+      nxt_string("false") },
+
+    { nxt_string("Object.valueOf.hasOwnProperty()"),
+      nxt_string("false") },
+
     { nxt_string("1..hasOwnProperty('b')"),
       nxt_string("false") },
 


More information about the nginx-devel mailing list