You've already forked node-redis
mirror of
https://github.com/redis/node-redis.git
synced 2025-08-06 02:15:48 +03:00
chore: guard against inherited properties
This commit is contained in:
14
index.js
14
index.js
@@ -40,10 +40,12 @@ function RedisClient (options, stream) {
|
|||||||
const cnxOptions = {}
|
const cnxOptions = {}
|
||||||
/* istanbul ignore next: travis does not work with stunnel atm. Therefore the tls tests are skipped on travis */
|
/* istanbul ignore next: travis does not work with stunnel atm. Therefore the tls tests are skipped on travis */
|
||||||
for (const tlsOption in options.tls) {
|
for (const tlsOption in options.tls) {
|
||||||
cnxOptions[tlsOption] = options.tls[tlsOption]
|
if (options.tls.hasOwnProperty(tlsOption)) {
|
||||||
// Copy the tls options into the general options to make sure the address is set right
|
cnxOptions[tlsOption] = options.tls[tlsOption]
|
||||||
if (tlsOption === 'port' || tlsOption === 'host' || tlsOption === 'path' || tlsOption === 'family') {
|
// Copy the tls options into the general options to make sure the address is set right
|
||||||
options[tlsOption] = options.tls[tlsOption]
|
if (tlsOption === 'port' || tlsOption === 'host' || tlsOption === 'path' || tlsOption === 'family') {
|
||||||
|
options[tlsOption] = options.tls[tlsOption]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (stream) {
|
if (stream) {
|
||||||
@@ -69,7 +71,9 @@ function RedisClient (options, stream) {
|
|||||||
options.socketKeepalive = true
|
options.socketKeepalive = true
|
||||||
}
|
}
|
||||||
for (const command in options.renameCommands) {
|
for (const command in options.renameCommands) {
|
||||||
options.renameCommands[command.toLowerCase()] = options.renameCommands[command]
|
if (options.renameCommands.hasOwnProperty(command)) {
|
||||||
|
options.renameCommands[command.toLowerCase()] = options.renameCommands[command]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
options.returnBuffers = !!options.returnBuffers
|
options.returnBuffers = !!options.returnBuffers
|
||||||
options.detectBuffers = !!options.detectBuffers
|
options.detectBuffers = !!options.detectBuffers
|
||||||
|
@@ -42,6 +42,9 @@ module.exports = function createClient (portArg, hostArg, options) {
|
|||||||
if (parsed.search !== '') {
|
if (parsed.search !== '') {
|
||||||
var elem
|
var elem
|
||||||
for (elem in parsed.query) {
|
for (elem in parsed.query) {
|
||||||
|
if (!parsed.query.hasOwnProperty(elem)) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
// If options are passed twice, only the parsed options will be used
|
// If options are passed twice, only the parsed options will be used
|
||||||
if (elem in options) {
|
if (elem in options) {
|
||||||
if (options[elem] === parsed.query[elem]) {
|
if (options[elem] === parsed.query[elem]) {
|
||||||
|
@@ -85,7 +85,9 @@ RedisClient.prototype.duplicate = function (options, callback) {
|
|||||||
const existingOptions = utils.clone(this.options)
|
const existingOptions = utils.clone(this.options)
|
||||||
options = utils.clone(options)
|
options = utils.clone(options)
|
||||||
for (const elem in options) {
|
for (const elem in options) {
|
||||||
existingOptions[elem] = options[elem]
|
if (options.hasOwnProperty(elem)) {
|
||||||
|
existingOptions[elem] = options[elem]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
const client = new RedisClient(existingOptions)
|
const client = new RedisClient(existingOptions)
|
||||||
client.selectedDb = this.selectedDb
|
client.selectedDb = this.selectedDb
|
||||||
|
@@ -72,13 +72,15 @@ function onReady (client) {
|
|||||||
if (!client.options.disableResubscribing && callbackCount) {
|
if (!client.options.disableResubscribing && callbackCount) {
|
||||||
debug('Sending pub/sub onReady commands')
|
debug('Sending pub/sub onReady commands')
|
||||||
for (const key in client.subscriptionSet) {
|
for (const key in client.subscriptionSet) {
|
||||||
const command = key.slice(0, key.indexOf('_'))
|
if (client.subscriptionSet.hasOwnProperty(key)) {
|
||||||
const args = client.subscriptionSet[key]
|
const command = key.slice(0, key.indexOf('_'))
|
||||||
client[command]([args]).catch((err) => {
|
const args = client.subscriptionSet[key]
|
||||||
if (!client.closing) {
|
client[command]([args]).catch((err) => {
|
||||||
process.nextTick(() => client.emit('error', err))
|
if (!client.closing) {
|
||||||
}
|
process.nextTick(() => client.emit('error', err))
|
||||||
})
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
client.sendOfflineQueue()
|
client.sendOfflineQueue()
|
||||||
|
Reference in New Issue
Block a user