Skip to content
Myr

Ignore Object.prototype values in settings through app.set/app.get

Before adoption: this commit came in with the history the project adopted, so no landing records it.

closes #4802 closes #4803

authored by Evan Hahn · committed by Douglas Christopher Wilson · parent 87279c0 · Browse files · 3 files+63 added−1 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

3 files+63 added−1 removed

  • tests:+44 added−0 removed
  • other:+19 added−1 removed

3 files+63 added−1 removed

modified:lib/application.js+18 added-1 removed
27 unmodified lines
28var flatten = require('array-flatten');29var merge = require('utils-merge');30var resolve = require('path').resolve;31var setPrototypeOf = require('setprototypeof')3233/**34 * Module variables.35 * @private36 */3738var hasOwnProperty = Object.prototype.hasOwnProperty39var slice = Array.prototype.slice;4041/**42 * Application prototype.
315 unmodified lines
358359app.set = function set(setting, val) {360 if (arguments.length === 1) {361 // app.get(setting)355 return this.settings[setting];362 var settings = this.settings363364 while (settings && settings !== Object.prototype) {365 if (hasOwnProperty.call(settings, setting)) {366 return settings[setting]367 }368369 settings = Object.getPrototypeOf(settings)370 }371372 return undefined373 }374375 debug('set "%s" to %o', setting, val);376
285 unmodified lines
modified:test/config.js+44 added
modified:History.md+1 added
1unreleased2==========34 * Ignore `Object.prototype` values in settings through `app.set`/`app.get`5 * Support proper 205 responses using `res.send`674.17.3 / 2022-02-168===================
3523 unmodified lines