@@ -925,6 +925,11 @@ lib.objectFromPath = function(path, value) {
925925var dottedPropertyRegex = / ^ ( [ ^ \[ \. ] + ) \. ( .+ ) ? / ;
926926var indexedPropertyRegex = / ^ ( [ ^ \. ] + ) \[ ( [ 0 - 9 ] + ) \] ( \. ) ? ( .+ ) ? / ;
927927
928+ function notValid ( prop ) {
929+ // guard against polluting __proto__ and other internals getters and setters
930+ return prop . slice ( 0 , 2 ) === '__' ;
931+ }
932+
928933lib . expandObjectPaths = function ( data ) {
929934 var match , key , prop , datum , idx , dest , trailingPath ;
930935 if ( typeof data === 'object' && ! Array . isArray ( data ) ) {
@@ -933,6 +938,7 @@ lib.expandObjectPaths = function(data) {
933938 if ( ( match = key . match ( dottedPropertyRegex ) ) ) {
934939 datum = data [ key ] ;
935940 prop = match [ 1 ] ;
941+ if ( notValid ( prop ) ) continue ;
936942
937943 delete data [ key ] ;
938944
@@ -941,6 +947,8 @@ lib.expandObjectPaths = function(data) {
941947 datum = data [ key ] ;
942948
943949 prop = match [ 1 ] ;
950+ if ( notValid ( prop ) ) continue ;
951+
944952 idx = parseInt ( match [ 2 ] ) ;
945953
946954 delete data [ key ] ;
@@ -969,9 +977,12 @@ lib.expandObjectPaths = function(data) {
969977 } else {
970978 // This is the case where this property is the end of the line,
971979 // e.g. xaxis.range[0]
980+
981+ if ( notValid ( prop ) ) continue ;
972982 data [ prop ] [ idx ] = lib . expandObjectPaths ( datum ) ;
973983 }
974984 } else {
985+ if ( notValid ( key ) ) continue ;
975986 data [ key ] = lib . expandObjectPaths ( data [ key ] ) ;
976987 }
977988 }
0 commit comments