1
0
mirror of https://github.com/redis/node-redis.git synced 2025-08-06 02:15:48 +03:00

Send the number of bytes, not characters. Fixes unrecoverable bug if multibyte characters are used.

This commit is contained in:
Orion Henry
2010-09-27 08:25:55 -07:00
parent aab093848f
commit 71763dcd66

View File

@@ -593,7 +593,7 @@ RedisClient.prototype.send_command = function () {
if (typeof arg !== "string") { if (typeof arg !== "string") {
arg = String(arg); arg = String(arg);
} }
command_str += "$" + arg.length + "\r\n" + arg + "\r\n"; command_str += "$" + Buffer.byteLength(arg) + "\r\n" + arg + "\r\n";
}); });
if (exports.debug_mode) { if (exports.debug_mode) {
console.log("send command: " + command_str); console.log("send command: " + command_str);
@@ -624,7 +624,7 @@ RedisClient.prototype.send_command = function () {
stream.write("\r\n"); stream.write("\r\n");
} }
} else { } else {
stream.write("$" + arg.length + "\r\n" + arg + "\r\n"); stream.write("$" + Buffer.byteLength(arg) + "\r\n" + arg + "\r\n");
} }
}); });
} }