-
Notifications
You must be signed in to change notification settings - Fork 208
/
proto.js
58 lines (55 loc) · 1.38 KB
/
proto.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
var ini = require('../')
var t = require('tap')
var data = `
__proto__ = quux
constructor.prototype.foo = asdfasdf
foo = baz
[__proto__]
foo = bar
[other]
foo = asdf
[kid.__proto__.foo]
foo = kid
[arrproto]
hello = snyk
__proto__[] = you did a good job
__proto__[] = so you deserve arrays
thanks = true
[ctor.constructor.prototype]
foo = asdfasdf
`
var res = ini.parse(data)
t.deepEqual(res, Object.assign(Object.create(null), {
'constructor.prototype.foo': 'asdfasdf',
foo: 'baz',
other: Object.assign(Object.create(null), {
foo: 'asdf',
}),
kid: Object.assign(Object.create(null), {
foo: Object.assign(Object.create(null), {
foo: 'kid',
}),
}),
arrproto: Object.assign(Object.create(null), {
hello: 'snyk',
thanks: true,
}),
ctor: Object.assign(Object.create(null), {
constructor: Object.assign(Object.create(null), {
prototype: Object.assign(Object.create(null), {
foo: 'asdfasdf',
}),
}),
}),
}))
t.equal(res.__proto__, undefined)
t.equal(res.kid.__proto__, undefined)
t.equal(res.kid.foo.__proto__, undefined)
t.equal(res.arrproto.__proto__, undefined)
t.equal(Object.prototype.foo, undefined)
t.equal(Object.prototype[0], undefined)
t.equal(Object.prototype['0'], undefined)
t.equal(Object.prototype[1], undefined)
t.equal(Object.prototype['1'], undefined)
t.equal(Array.prototype[0], undefined)
t.equal(Array.prototype[1], undefined)