Skip to content

Commit 95e9d99

Browse files
committed
disallow proto keys
1 parent 7bd5011 commit 95e9d99

File tree

6 files changed

+39
-28
lines changed

6 files changed

+39
-28
lines changed

.travis.yml

+4
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,13 @@ sudo: false
22
os:
33
- linux
44
- osx
5+
- windows
56
language: node_js
67
node_js:
78
- node
9+
- '12'
10+
- '11'
11+
- '10'
812
- '9'
913
- '8'
1014
- '7'

.verb.md

+7-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
1+
## Heads up!
2+
3+
[Please update][update] to version 3.0.1 or later, a critical bug was fixed in that version.
4+
15
## Usage
26

37
```js
4-
var set = require('{%= name %}');
8+
const set = require('{%= name %}');
59
set(object, prop, value);
610
```
711

@@ -17,7 +21,7 @@ set(object, prop, value);
1721
Updates and returns the given object:
1822

1923
```js
20-
var obj = {};
24+
const obj = {};
2125
set(obj, 'a.b.c', 'd');
2226
console.log(obj);
2327
//=> { a: { b: { c: 'd' } } }
@@ -104,4 +108,4 @@ These are just a few of the duplicate libraries on NPM.
104108
- Adds support for escaping with double or single quotes. See [escaping](#escaping) for examples.
105109
- Will no longer split inside brackets or braces. See [bracket support](#bracket-support) for examples.
106110

107-
If there are any regressions please create a [bug report](../../issues/new). Thanks!
111+
If there are any regressions please create a [bug report](../../issues/new). Thanks!

LICENSE

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
The MIT License (MIT)
22

3-
Copyright (c) 2014-2018, Jon Schlinkert.
3+
Copyright (c) 2014-present, Jon Schlinkert.
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

+16-11
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# set-value [![NPM version](https://img.shields.io/npm/v/set-value.svg?style=flat)](https://www.npmjs.com/package/set-value) [![NPM monthly downloads](https://img.shields.io/npm/dm/set-value.svg?style=flat)](https://npmjs.org/package/set-value) [![NPM total downloads](https://img.shields.io/npm/dt/set-value.svg?style=flat)](https://npmjs.org/package/set-value) [![Linux Build Status](https://img.shields.io/travis/jonschlinkert/set-value.svg?style=flat&label=Travis)](https://travis-ci.org/jonschlinkert/set-value)
1+
# set-value [![Donate](https://img.shields.io/badge/Donate-PayPal-green.svg)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=W8YFZ425KND68) [![NPM version](https://img.shields.io/npm/v/set-value.svg?style=flat)](https://www.npmjs.com/package/set-value) [![NPM monthly downloads](https://img.shields.io/npm/dm/set-value.svg?style=flat)](https://npmjs.org/package/set-value) [![NPM total downloads](https://img.shields.io/npm/dt/set-value.svg?style=flat)](https://npmjs.org/package/set-value) [![Linux Build Status](https://img.shields.io/travis/jonschlinkert/set-value.svg?style=flat&label=Travis)](https://travis-ci.org/jonschlinkert/set-value)
22

33
> Create nested values and any intermediaries using dot notation (`'a.b.c'`) paths.
44
@@ -12,10 +12,14 @@ Install with [npm](https://www.npmjs.com/):
1212
$ npm install --save set-value
1313
```
1414

15+
## Heads up!
16+
17+
[Please update](https://github.com/update/update) to version 3.0.1 or later, a critical bug was fixed in that version.
18+
1519
## Usage
1620

1721
```js
18-
var set = require('set-value');
22+
const set = require('set-value');
1923
set(object, prop, value);
2024
```
2125

@@ -30,7 +34,7 @@ set(object, prop, value);
3034
Updates and returns the given object:
3135

3236
```js
33-
var obj = {};
37+
const obj = {};
3438
set(obj, 'a.b.c', 'd');
3539
console.log(obj);
3640
//=> { a: { b: { c: 'd' } } }
@@ -210,25 +214,26 @@ You might also be interested in these projects:
210214

211215
### Contributors
212216

213-
| **Commits** | **Contributor** |
214-
| --- | --- |
215-
| 64 | [jonschlinkert](https://github.com/jonschlinkert) |
216-
| 1 | [vadimdemedes](https://github.com/vadimdemedes) |
217-
| 1 | [wtgtybhertgeghgtwtg](https://github.com/wtgtybhertgeghgtwtg) |
217+
| **Commits** | **Contributor** |
218+
| --- | --- |
219+
| 71 | [jonschlinkert](https://github.com/jonschlinkert) |
220+
| 2 | [mbelsky](https://github.com/mbelsky) |
221+
| 1 | [vadimdemedes](https://github.com/vadimdemedes) |
222+
| 1 | [wtgtybhertgeghgtwtg](https://github.com/wtgtybhertgeghgtwtg) |
218223

219224
### Author
220225

221226
**Jon Schlinkert**
222227

223-
* [LinkedIn Profile](https://linkedin.com/in/jonschlinkert)
224228
* [GitHub Profile](https://github.com/jonschlinkert)
225229
* [Twitter Profile](https://twitter.com/jonschlinkert)
230+
* [LinkedIn Profile](https://linkedin.com/in/jonschlinkert)
226231

227232
### License
228233

229-
Copyright © 2018, [Jon Schlinkert](https://github.com/jonschlinkert).
234+
Copyright © 2019, [Jon Schlinkert](https://github.com/jonschlinkert).
230235
Released under the [MIT License](LICENSE).
231236

232237
***
233238

234-
_This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.6.0, on March 05, 2018._
239+
_This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.8.0, on June 19, 2019._

index.js

+6-10
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ function set(target, path, value, options) {
2525
merge = Object.assign;
2626
}
2727

28-
const keys = isArray ? path : split(path, opts);
28+
const keys = (isArray ? path : split(path, opts)).filter(isValidKey);
2929
const len = keys.length;
3030
const orig = target;
3131

@@ -98,16 +98,12 @@ function createKey(pattern, options) {
9898
return id;
9999
}
100100

101+
function isValidKey(key) {
102+
return key !== '__proto__' && key !== 'constructor' && key !== 'prototype';
103+
}
104+
101105
function isObject(val) {
102-
switch (typeof val) {
103-
case 'object':
104-
return val !== null;
105-
case 'function':
106-
return true;
107-
default: {
108-
return false;
109-
}
110-
}
106+
return val !== null && (typeof val === 'object' || typeof val === 'function');
111107
}
112108

113109
set.memo = {};

package.json

+5-3
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
"dot-prop": "^4.2.0",
3737
"dot2val": "^1.2.2",
3838
"es5-dot-prop": "^4.1.1",
39-
"gulp-format-md": "^1.0.0",
39+
"gulp-format-md": "^2.0.0",
4040
"lodash.set": "^4.3.2",
4141
"minimist": "^1.2.0",
4242
"mocha": "^3.5.3",
@@ -124,7 +124,9 @@
124124
"set-deep",
125125
"set-deep-prop",
126126
"set-nested-prop",
127-
"setvalue"
127+
"setvalue",
128+
"split-string",
129+
"update"
128130
]
129131
}
130-
}
132+
}

0 commit comments

Comments
 (0)