File tree Expand file tree Collapse file tree 1 file changed +22
-17
lines changed
Expand file tree Collapse file tree 1 file changed +22
-17
lines changed Original file line number Diff line number Diff line change @@ -113,23 +113,28 @@ function getValueAtPath(obj, path) {
113113
114114// Set value at a dotted path in an object
115115function setValueAtPath ( obj , path , value ) {
116- const parts = path . split ( "." )
117- let current = obj
118-
119- for ( let i = 0 ; i < parts . length ; i ++ ) {
120- const part = parts [ i ]
121-
122- // If it's the last part, set the value
123- if ( i === parts . length - 1 ) {
124- current [ part ] = value
125- } else {
126- // If the key doesn't exist or isn't an object, create an empty object
127- if ( current [ part ] === undefined || typeof current [ part ] !== "object" ) {
128- current [ part ] = { }
129- }
130- current = current [ part ]
131- }
132- }
116+ const parts = path . split ( "." )
117+ let current = obj
118+
119+ for ( let i = 0 ; i < parts . length ; i ++ ) {
120+ const part = parts [ i ]
121+
122+ // Guard against prototype pollution
123+ if ( part === "__proto__" || part === "constructor" || part === "prototype" ) {
124+ continue
125+ }
126+
127+ // If it's the last part, set the value
128+ if ( i === parts . length - 1 ) {
129+ current [ part ] = value
130+ } else {
131+ // If the key doesn't exist or isn't an object, create an empty object
132+ if ( current [ part ] === undefined || typeof current [ part ] !== "object" ) {
133+ current [ part ] = { }
134+ }
135+ current = current [ part ]
136+ }
137+ }
133138}
134139
135140// Function to check translations for a specific area
You can’t perform that action at this time.
0 commit comments