@@ -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
}
0 commit comments