You've already forked node-redis
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:
4
index.js
4
index.js
@@ -593,7 +593,7 @@ RedisClient.prototype.send_command = function () {
|
||||
if (typeof arg !== "string") {
|
||||
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) {
|
||||
console.log("send command: " + command_str);
|
||||
@@ -624,7 +624,7 @@ RedisClient.prototype.send_command = function () {
|
||||
stream.write("\r\n");
|
||||
}
|
||||
} else {
|
||||
stream.write("$" + arg.length + "\r\n" + arg + "\r\n");
|
||||
stream.write("$" + Buffer.byteLength(arg) + "\r\n" + arg + "\r\n");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
Reference in New Issue
Block a user