From 257233be51501f500fa6702737162115811d8ea1 Mon Sep 17 00:00:00 2001 From: Stefan Siegl Date: Sat, 19 Oct 2013 02:22:13 +0200 Subject: [PATCH] Make php_v8js_write_property export only public properties Before a property would have been exported, even if a derived class declared it either private or protected. --- v8js.cc | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/v8js.cc b/v8js.cc index daccd7f..a86b195 100644 --- a/v8js.cc +++ b/v8js.cc @@ -1296,12 +1296,16 @@ static void php_v8js_write_property(zval *object, zval *member, zval *value ZEND { V8JS_BEGIN_CTX(c, object) - /* Global PHP JS object */ - v8::Local object_name_js = v8::Local::New(c->isolate, c->object_name); - v8::Local jsobj = V8JS_GLOBAL->Get(object_name_js)->ToObject(); + /* Check whether member is public, if so, export to V8. */ + zend_property_info *property_info = zend_get_property_info(c->std.ce, member, 1 TSRMLS_CC); + if(property_info->flags & ZEND_ACC_PUBLIC) { + /* Global PHP JS object */ + v8::Local object_name_js = v8::Local::New(c->isolate, c->object_name); + v8::Local jsobj = V8JS_GLOBAL->Get(object_name_js)->ToObject(); - /* Write value to PHP JS object */ - jsobj->ForceSet(V8JS_SYML(Z_STRVAL_P(member), Z_STRLEN_P(member)), zval_to_v8js(value, c->isolate TSRMLS_CC), v8::ReadOnly); + /* Write value to PHP JS object */ + jsobj->ForceSet(V8JS_SYML(Z_STRVAL_P(member), Z_STRLEN_P(member)), zval_to_v8js(value, c->isolate TSRMLS_CC), v8::ReadOnly); + } /* Write value to PHP object */ std_object_handlers.write_property(object, member, value ZEND_HASH_KEY_CC TSRMLS_CC);