@@ -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,7 +938,7 @@ lib.expandObjectPaths = function(data) {
933938 if ( ( match = key . match ( dottedPropertyRegex ) ) ) {
934939 datum = data [ key ] ;
935940 prop = match [ 1 ] ;
936- if ( prop === '__proto__' ) continue ;
941+ if ( notValid ( prop ) ) continue ;
937942
938943 delete data [ key ] ;
939944
@@ -942,7 +947,7 @@ lib.expandObjectPaths = function(data) {
942947 datum = data [ key ] ;
943948
944949 prop = match [ 1 ] ;
945- if ( prop === '__proto__' ) continue ;
950+ if ( notValid ( prop ) ) continue ;
946951
947952 idx = parseInt ( match [ 2 ] ) ;
948953
@@ -973,11 +978,11 @@ lib.expandObjectPaths = function(data) {
973978 // This is the case where this property is the end of the line,
974979 // e.g. xaxis.range[0]
975980
976- if ( prop === '__proto__' ) continue ;
981+ if ( notValid ( prop ) ) continue ;
977982 data [ prop ] [ idx ] = lib . expandObjectPaths ( datum ) ;
978983 }
979984 } else {
980- if ( key === '__proto__' ) continue ;
985+ if ( notValid ( key ) ) continue ;
981986 data [ key ] = lib . expandObjectPaths ( data [ key ] ) ;
982987 }
983988 }
@@ -1065,7 +1070,7 @@ lib.templateString = function(string, obj) {
10651070 getterCache [ key ] = getterCache [ key ] || lib . nestedProperty ( obj , key ) . get ;
10661071 v = getterCache [ key ] ( ) ;
10671072 }
1068- return lib . isValidTextValue ( v ) ? v : '' ;
1073+ return lib . notValidTextValue ( v ) ? v : '' ;
10691074 } ) ;
10701075} ;
10711076
@@ -1298,14 +1303,14 @@ lib.fillText = function(calcPt, trace, contOut) {
12981303 function ( v ) { contOut . text = v ; } ;
12991304
13001305 var htx = lib . extractOption ( calcPt , trace , 'htx' , 'hovertext' ) ;
1301- if ( lib . isValidTextValue ( htx ) ) return fill ( htx ) ;
1306+ if ( lib . notValidTextValue ( htx ) ) return fill ( htx ) ;
13021307
13031308 var tx = lib . extractOption ( calcPt , trace , 'tx' , 'text' ) ;
1304- if ( lib . isValidTextValue ( tx ) ) return fill ( tx ) ;
1309+ if ( lib . notValidTextValue ( tx ) ) return fill ( tx ) ;
13051310} ;
13061311
13071312// accept all truthy values and 0 (which gets cast to '0' in the hover labels)
1308- lib . isValidTextValue = function ( v ) {
1313+ lib . notValidTextValue = function ( v ) {
13091314 return v || v === 0 ;
13101315} ;
13111316
0 commit comments