Skip to content

Commit a57c4cf

Browse files
committed
Use null prototype for Object literals.
This prevents inadvertent leakage of `Object` properties into the map.
1 parent 3cd74e5 commit a57c4cf

File tree

7 files changed

+11
-2
lines changed

7 files changed

+11
-2
lines changed

.jshintrc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,6 @@
55
"evil": true,
66
"loopfunc": true,
77
"undef": true,
8-
"rhino": false
8+
"rhino": false,
9+
"proto": true
910
}

build.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@
120120
<fileset dir="${src.dir}/util" includes="*.js" />
121121
<footer trimleading="yes">
122122
parserlib.util = {
123+
__proto__ : null,
123124
StringReader: StringReader,
124125
SyntaxError : SyntaxError,
125126
SyntaxUnit : SyntaxUnit,
@@ -150,6 +151,7 @@
150151
<fileset dir="${src.dir}/css" includes="*.js" />
151152
<footer trimleading="yes">
152153
parserlib.css = {
154+
__proto__ :null,
153155
Colors :Colors,
154156
Combinator :Combinator,
155157
Parser :Parser,

src/css/Colors.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11

22
var Colors = {
3+
__proto__ :null,
34
aliceblue :"#f0f8ff",
45
antiquewhite :"#faebd7",
56
aqua :"#00ffff",

src/css/Parser.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ Parser.prototype = function(){
4343
var proto = new EventTarget(), //new prototype
4444
prop,
4545
additions = {
46+
__proto__: null,
4647

4748
//restore constructor
4849
constructor: Parser,
@@ -2363,7 +2364,7 @@ Parser.prototype = function(){
23632364

23642365
//copy over onto prototype
23652366
for (prop in additions){
2366-
if (additions.hasOwnProperty(prop)){
2367+
if (Object.prototype.hasOwnProperty.call(additions, prop)){
23672368
proto[prop] = additions[prop];
23682369
}
23692370
}

src/css/Properties.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/*global Validation, ValidationTypes, ValidationError*/
22
var Properties = {
3+
__proto__: null,
34

45
//A
56
"align-items" : "flex-start | flex-end | center | baseline | stretch",

src/css/Pseudos.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
var Pseudos = {
2+
__proto__: null,
23
":first-letter": 1,
34
":first-line": 1,
45
":before": 1,

src/css/ValidationTypes.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ var ValidationTypes = {
8282

8383

8484
simple: {
85+
__proto__: null,
8586

8687
"<absolute-size>": function(part){
8788
return ValidationTypes.isLiteral(part, "xx-small | x-small | small | medium | large | x-large | xx-large");
@@ -256,6 +257,7 @@ var ValidationTypes = {
256257
},
257258

258259
complex: {
260+
__proto__: null,
259261

260262
"<bg-position>": function(expression){
261263
var result = false,

0 commit comments

Comments
 (0)