Skip to content

Commit 68d1b9e

Browse files
committed
Use object with null prototype for various app properties
`app.cache`, `app.engines`, and `app.settings` are now created with `Object.create(null)` instead of `{}`. This also updates a test to ensure that `app.locals` is created the same way.
1 parent cd7d79f commit 68d1b9e

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

lib/application.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,9 @@ var trustProxyDefaultSymbol = '@@symbol:trust_proxy_default';
6161
app.init = function init() {
6262
var router = null;
6363

64-
this.cache = {};
65-
this.engines = {};
66-
this.settings = {};
64+
this.cache = Object.create(null);
65+
this.engines = Object.create(null);
66+
this.settings = Object.create(null);
6767

6868
this.defaultConfiguration();
6969

test/app.locals.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,11 @@ var express = require('../')
55

66
describe('app', function(){
77
describe('.locals', function () {
8-
it('should default object', function () {
8+
it('should default object with null prototype', function () {
99
var app = express()
1010
assert.ok(app.locals)
1111
assert.strictEqual(typeof app.locals, 'object')
12+
assert.strictEqual(Object.getPrototypeOf(app.locals), null)
1213
})
1314

1415
describe('.settings', function () {

0 commit comments

Comments
 (0)