diff --git a/core/frontend/apps/subscribers/lib/router.js b/core/frontend/apps/subscribers/lib/router.js index f0f3e0ce9d..6c971d6e16 100644 --- a/core/frontend/apps/subscribers/lib/router.js +++ b/core/frontend/apps/subscribers/lib/router.js @@ -45,7 +45,7 @@ function errorHandler(error, req, res, next) { } function honeyPot(req, res, next) { - if (!req.body.hasOwnProperty('confirm') || req.body.confirm !== '') { + if (!Object.prototype.hasOwnProperty.call(req.body, 'confirm') || req.body.confirm !== '') { return next(new Error('Oops, something went wrong!')); } diff --git a/core/frontend/helpers/content.js b/core/frontend/helpers/content.js index 4cf71ed679..535d83c771 100644 --- a/core/frontend/helpers/content.js +++ b/core/frontend/helpers/content.js @@ -15,7 +15,7 @@ module.exports = function content(options = {}) { let runTruncate = false; for (const key of ['words', 'characters']) { - if (hash.hasOwnProperty(key)) { + if (Object.prototype.hasOwnProperty.call(hash, key)) { runTruncate = true; truncateOptions[key] = parseInt(hash[key], 10); } diff --git a/core/frontend/helpers/date.js b/core/frontend/helpers/date.js index 1cabcb16fc..9ff37f9a97 100644 --- a/core/frontend/helpers/date.js +++ b/core/frontend/helpers/date.js @@ -9,7 +9,7 @@ const moment = require('moment-timezone'); module.exports = function (date, options) { let timezone; - if (!options && date.hasOwnProperty('hash')) { + if (!options && Object.prototype.hasOwnProperty.call(date, 'hash')) { options = date; date = undefined; timezone = options.data.blog.timezone; diff --git a/core/frontend/helpers/t.js b/core/frontend/helpers/t.js index 07a33c42d4..e3acbc4165 100644 --- a/core/frontend/helpers/t.js +++ b/core/frontend/helpers/t.js @@ -17,7 +17,7 @@ module.exports = function t(text, options) { var bindings = {}, prop; for (prop in options.hash) { - if (options.hash.hasOwnProperty(prop)) { + if (Object.prototype.hasOwnProperty.call(options.hash, prop)) { bindings[prop] = options.hash[prop]; } } diff --git a/core/frontend/services/routing/helpers/fetch-data.js b/core/frontend/services/routing/helpers/fetch-data.js index 49a8444248..eaf1b3c227 100644 --- a/core/frontend/services/routing/helpers/fetch-data.js +++ b/core/frontend/services/routing/helpers/fetch-data.js @@ -90,11 +90,11 @@ function fetchData(pathOptions, routerOptions, locals) { postQuery.options.order = routerOptions.order; } - if (pathOptions.hasOwnProperty('page')) { + if (Object.prototype.hasOwnProperty.call(pathOptions, 'page')) { postQuery.options.page = pathOptions.page; } - if (pathOptions.hasOwnProperty('limit')) { + if (Object.prototype.hasOwnProperty.call(pathOptions, 'limit')) { postQuery.options.limit = pathOptions.limit; } diff --git a/core/frontend/services/settings/validate.js b/core/frontend/services/settings/validate.js index fd7e7f292c..b076ed99c9 100644 --- a/core/frontend/services/settings/validate.js +++ b/core/frontend/services/settings/validate.js @@ -13,7 +13,7 @@ _private.validateTemplate = function validateTemplate(object) { }; } - if (!object.hasOwnProperty('template')) { + if (!Object.prototype.hasOwnProperty.call(object, 'template')) { object.templates = []; return object; } @@ -29,7 +29,7 @@ _private.validateTemplate = function validateTemplate(object) { }; _private.validateData = function validateData(object) { - if (!object.hasOwnProperty('data')) { + if (!Object.prototype.hasOwnProperty.call(object, 'data')) { return object; } @@ -51,7 +51,7 @@ _private.validateData = function validateData(object) { let [resourceKey, slug] = shortForm.split('.'); if (!RESOURCE_CONFIG.QUERY[resourceKey] || - (RESOURCE_CONFIG.QUERY[resourceKey].hasOwnProperty('internal') && RESOURCE_CONFIG.QUERY[resourceKey].internal === true)) { + (Object.prototype.hasOwnProperty.call(RESOURCE_CONFIG.QUERY[resourceKey], 'internal') && RESOURCE_CONFIG.QUERY[resourceKey].internal === true)) { throw new common.errors.ValidationError({ message: `Resource key not supported. ${resourceKey}`, help: 'Please use: tag, user, post or page.' @@ -130,7 +130,7 @@ _private.validateData = function validateData(object) { }; _.each(requiredQueryFields, (option) => { - if (!object.data[key].hasOwnProperty(option)) { + if (!Object.prototype.hasOwnProperty.call(object.data[key], option)) { throw new common.errors.ValidationError({ message: common.i18n.t('errors.services.settings.yaml.validate', { at: JSON.stringify(object.data[key]), @@ -162,7 +162,7 @@ _private.validateData = function validateData(object) { data.query[key].options = _.defaults(data.query[key].options, DEFAULT_RESOURCE.options); } - if (!data.router.hasOwnProperty(DEFAULT_RESOURCE.resourceAlias || DEFAULT_RESOURCE.resource)) { + if (!Object.prototype.hasOwnProperty.call(data.router, DEFAULT_RESOURCE.resourceAlias || DEFAULT_RESOURCE.resource)) { data.router[DEFAULT_RESOURCE.resourceAlias || DEFAULT_RESOURCE.resource] = []; } @@ -244,7 +244,7 @@ _private.validateCollections = function validateCollections(collections) { }); } - if (!routingTypeObject.hasOwnProperty('permalink')) { + if (!Object.prototype.hasOwnProperty.call(routingTypeObject, 'permalink')) { throw new common.errors.ValidationError({ message: common.i18n.t('errors.services.settings.yaml.validate', { at: routingTypeObjectKey, diff --git a/core/frontend/services/sitemap/handler.js b/core/frontend/services/sitemap/handler.js index 85b9c9c9c5..e0434e1a4e 100644 --- a/core/frontend/services/sitemap/handler.js +++ b/core/frontend/services/sitemap/handler.js @@ -5,7 +5,7 @@ const config = require('../../../server/config'), // Responsible for handling requests for sitemap files module.exports = function handler(siteApp) { const verifyResourceType = function verifyResourceType(req, res, next) { - if (!manager.hasOwnProperty(req.params.resource)) { + if (!Object.prototype.hasOwnProperty.call(manager, req.params.resource)) { return res.sendStatus(404); } diff --git a/core/frontend/services/themes/config/index.js b/core/frontend/services/themes/config/index.js index 7daafabc29..946a5cb7b1 100644 --- a/core/frontend/services/themes/config/index.js +++ b/core/frontend/services/themes/config/index.js @@ -5,7 +5,7 @@ var _ = require('lodash'), module.exports.create = function configLoader(packageJson) { var config = _.cloneDeep(defaultConfig); - if (packageJson && packageJson.hasOwnProperty('config')) { + if (packageJson && Object.prototype.hasOwnProperty.call(packageJson, 'config')) { config = _.assign(config, _.pick(packageJson.config, allowedKeys)); } diff --git a/core/frontend/services/themes/engines/create.js b/core/frontend/services/themes/engines/create.js index 0af48a0aeb..aec976619d 100644 --- a/core/frontend/services/themes/engines/create.js +++ b/core/frontend/services/themes/engines/create.js @@ -23,7 +23,7 @@ const allowedKeys = ['ghost-api']; module.exports = (packageJson) => { let themeEngines = _.cloneDeep(DEFAULTS); - if (packageJson && packageJson.hasOwnProperty('engines')) { + if (packageJson && Object.prototype.hasOwnProperty.call(packageJson, 'engines')) { // CASE: validate if (packageJson.engines['ghost-api']) { const availableApiVersions = {}; diff --git a/core/frontend/services/url/Queue.js b/core/frontend/services/url/Queue.js index ab0c489e02..cd8d17cfb6 100644 --- a/core/frontend/services/url/Queue.js +++ b/core/frontend/services/url/Queue.js @@ -79,12 +79,12 @@ class Queue extends EventEmitter { * @param {function} fn */ register(options, fn) { - if (!options.hasOwnProperty('tolerance')) { + if (!Object.prototype.hasOwnProperty.call(options, 'tolerance')) { options.tolerance = 0; } // CASE: nobody has initialised the queue event yet - if (!this.queue.hasOwnProperty(options.event)) { + if (!Object.prototype.hasOwnProperty.call(this.queue, options.event)) { this.queue[options.event] = { tolerance: options.tolerance, requiredSubscriberCount: options.requiredSubscriberCount || 0, @@ -178,7 +178,7 @@ class Queue extends EventEmitter { // CASE: nobody is in the event queue waiting yet // e.g. all resources are fetched already, but no subscribers (bootstrap) // happens only for high tolerant events - if (!this.queue.hasOwnProperty(options.event)) { + if (!Object.prototype.hasOwnProperty.call(this.queue, options.event)) { this.queue[options.event] = { tolerance: options.tolerance || 0, requiredSubscriberCount: options.requiredSubscriberCount || 0,