@@ -76,13 +76,20 @@ function parsePath(path) {
7676 var str = path . replace ( / ( [ ^ \\ ] ) \[ / g, '$1.[' ) ;
7777 var parts = str . match ( / ( \\ \. | [ ^ . ] + ?) + / g) ;
7878 return parts . map ( function mapMatches ( value ) {
79+ if (
80+ value === 'constructor' ||
81+ value === '__proto__' ||
82+ value === 'prototype'
83+ ) {
84+ return { } ;
85+ }
7986 var regexp = / ^ \[ ( \d + ) \] $ / ;
8087 var mArr = regexp . exec ( value ) ;
8188 var parsed = null ;
8289 if ( mArr ) {
8390 parsed = { i : parseFloat ( mArr [ 1 ] ) } ;
8491 } else {
85- parsed = { p : value . replace ( / \\ ( [ . \ [\] ] ) / g, '$1' ) } ;
92+ parsed = { p : value . replace ( / \\ ( [ . [ \] ] ) / g, '$1' ) } ;
8693 }
8794
8895 return parsed ;
@@ -107,7 +114,7 @@ function parsePath(path) {
107114function internalGetPathValue ( obj , parsed , pathDepth ) {
108115 var temporaryValue = obj ;
109116 var res = null ;
110- pathDepth = ( typeof pathDepth === 'undefined' ? parsed . length : pathDepth ) ;
117+ pathDepth = typeof pathDepth === 'undefined' ? parsed . length : pathDepth ;
111118
112119 for ( var i = 0 ; i < pathDepth ; i ++ ) {
113120 var part = parsed [ i ] ;
@@ -118,7 +125,7 @@ function internalGetPathValue(obj, parsed, pathDepth) {
118125 temporaryValue = temporaryValue [ part . p ] ;
119126 }
120127
121- if ( i === ( pathDepth - 1 ) ) {
128+ if ( i === pathDepth - 1 ) {
122129 res = temporaryValue ;
123130 }
124131 }
@@ -152,7 +159,7 @@ function internalSetPathValue(obj, val, parsed) {
152159 part = parsed [ i ] ;
153160
154161 // If it's the last part of the path, we set the 'propName' value with the property name
155- if ( i === ( pathDepth - 1 ) ) {
162+ if ( i === pathDepth - 1 ) {
156163 propName = typeof part . p === 'undefined' ? part . i : part . p ;
157164 // Now we set the property with the name held by 'propName' on object with the desired val
158165 tempObj [ propName ] = val ;
@@ -199,7 +206,10 @@ function getPathInfo(obj, path) {
199206 var parsed = parsePath ( path ) ;
200207 var last = parsed [ parsed . length - 1 ] ;
201208 var info = {
202- parent : parsed . length > 1 ? internalGetPathValue ( obj , parsed , parsed . length - 1 ) : obj ,
209+ parent :
210+ parsed . length > 1 ?
211+ internalGetPathValue ( obj , parsed , parsed . length - 1 ) :
212+ obj ,
203213 name : last . p || last . i ,
204214 value : internalGetPathValue ( obj , parsed ) ,
205215 } ;
0 commit comments