Skip to content

Commit

Permalink
add if (!value.hasOwnProperty(vKey)) continue; that occurred bugs!
Browse files Browse the repository at this point in the history
  • Loading branch information
XadillaX committed Mar 2, 2015
1 parent 5f58e12 commit 2739d8e
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 7 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
node_modules
.idea
*.swp
*.log

11 changes: 4 additions & 7 deletions lib/memcached.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@ var curry = Utils.curry;
function Client (args, options) {
var servers = []
, weights = {}
, regular = 'localhost:11211'
, key;
, regular = 'localhost:11211';

// Parse down the connection arguments
switch (Object.prototype.toString.call(args)) {
Expand Down Expand Up @@ -112,8 +111,7 @@ Client.config = {
nMemcached.prototype.__proto__ = require('events').EventEmitter.prototype;

var memcached = nMemcached.prototype
, privates = {}
, undefined;
, privates = {};

// Creates or generates a new connection for the give server, the callback
// will receive the connection if the operation was successful
Expand Down Expand Up @@ -319,7 +317,7 @@ Client.config = {
var S = {
serverAddress: server,
tokens: server.split(':').reverse()
}
};
var message = error || 'Unable to connect to server';
memcached.connectionIssue(message, S);
return query.callback && memcached.makeCallback(query.callback,new Error(message));
Expand Down Expand Up @@ -706,8 +704,7 @@ Client.config = {
, dataSet
, resultSet
, metaData
, err = []
, tmp;
, err = [];

while(S.bufferArray.length && privates.allCommands.test(S.bufferArray[0])) {
token = S.bufferArray.shift();
Expand Down
9 changes: 9 additions & 0 deletions lib/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,13 @@ exports.validateArg = function validateArg (args, config) {
}
if (!err && key === 'key') {
for (var vKey in value) {
if (!value.hasOwnProperty(vKey)) continue;
var vValue = value[vKey];
var result = validateKeySize(config, vKey, vValue);
if (result.err) {
if (result.err === 'function') {
continue;
}
err = result.err;
} else {
args.command = args.command.replace(vValue, result['value']);
Expand Down Expand Up @@ -87,6 +91,10 @@ exports.validateArg = function validateArg (args, config) {
};

var validateKeySize = function validateKeySize(config, key, value) {
if (typeof value === 'function') {
return { err: 'function' };
}

if (value.length > config.maxKeySize) {
if (config.keyCompression){
return { err: false, value: createHash('md5').update(value).digest('hex') };
Expand All @@ -111,6 +119,7 @@ exports.fuse = function fuse (target, handlers) {
// merges a object's proppertys / values with a other object
exports.merge = function merge (target, obj) {
for (var i in obj) {
if (!obj.hasOwnProperty(i)) continue;
target[i] = obj[i];
}

Expand Down

0 comments on commit 2739d8e

Please sign in to comment.