@@ -925,6 +925,11 @@ lib.objectFromPath = function(path, value) {
925
925
var dottedPropertyRegex = / ^ ( [ ^ \[ \. ] + ) \. ( .+ ) ? / ;
926
926
var indexedPropertyRegex = / ^ ( [ ^ \. ] + ) \[ ( [ 0 - 9 ] + ) \] ( \. ) ? ( .+ ) ? / ;
927
927
928
+ function notValid ( prop ) {
929
+ // guard against polluting __proto__ and other internals getters and setters
930
+ return prop . slice ( 0 , 2 ) === '__' ;
931
+ }
932
+
928
933
lib . expandObjectPaths = function ( data ) {
929
934
var match , key , prop , datum , idx , dest , trailingPath ;
930
935
if ( typeof data === 'object' && ! Array . isArray ( data ) ) {
@@ -933,7 +938,7 @@ lib.expandObjectPaths = function(data) {
933
938
if ( ( match = key . match ( dottedPropertyRegex ) ) ) {
934
939
datum = data [ key ] ;
935
940
prop = match [ 1 ] ;
936
- if ( prop === '__proto__' ) continue ;
941
+ if ( notValid ( prop ) ) continue ;
937
942
938
943
delete data [ key ] ;
939
944
@@ -942,7 +947,7 @@ lib.expandObjectPaths = function(data) {
942
947
datum = data [ key ] ;
943
948
944
949
prop = match [ 1 ] ;
945
- if ( prop === '__proto__' ) continue ;
950
+ if ( notValid ( prop ) ) continue ;
946
951
947
952
idx = parseInt ( match [ 2 ] ) ;
948
953
@@ -973,11 +978,11 @@ lib.expandObjectPaths = function(data) {
973
978
// This is the case where this property is the end of the line,
974
979
// e.g. xaxis.range[0]
975
980
976
- if ( prop === '__proto__' ) continue ;
981
+ if ( notValid ( prop ) ) continue ;
977
982
data [ prop ] [ idx ] = lib . expandObjectPaths ( datum ) ;
978
983
}
979
984
} else {
980
- if ( key === '__proto__' ) continue ;
985
+ if ( notValid ( key ) ) continue ;
981
986
data [ key ] = lib . expandObjectPaths ( data [ key ] ) ;
982
987
}
983
988
}
@@ -1065,7 +1070,7 @@ lib.templateString = function(string, obj) {
1065
1070
getterCache [ key ] = getterCache [ key ] || lib . nestedProperty ( obj , key ) . get ;
1066
1071
v = getterCache [ key ] ( ) ;
1067
1072
}
1068
- return lib . isValidTextValue ( v ) ? v : '' ;
1073
+ return lib . notValidTextValue ( v ) ? v : '' ;
1069
1074
} ) ;
1070
1075
} ;
1071
1076
@@ -1298,14 +1303,14 @@ lib.fillText = function(calcPt, trace, contOut) {
1298
1303
function ( v ) { contOut . text = v ; } ;
1299
1304
1300
1305
var htx = lib . extractOption ( calcPt , trace , 'htx' , 'hovertext' ) ;
1301
- if ( lib . isValidTextValue ( htx ) ) return fill ( htx ) ;
1306
+ if ( lib . notValidTextValue ( htx ) ) return fill ( htx ) ;
1302
1307
1303
1308
var tx = lib . extractOption ( calcPt , trace , 'tx' , 'text' ) ;
1304
- if ( lib . isValidTextValue ( tx ) ) return fill ( tx ) ;
1309
+ if ( lib . notValidTextValue ( tx ) ) return fill ( tx ) ;
1305
1310
} ;
1306
1311
1307
1312
// 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 ) {
1309
1314
return v || v === 0 ;
1310
1315
} ;
1311
1316
0 commit comments