You've already forked node-redis
mirror of
https://github.com/redis/node-redis.git
synced 2025-08-06 02:15:48 +03:00
Fix parser being reset in case (p)message_buffer is attached
without the parser set to return buffers. This might result in corrupt data if the listener is attached while the parser holds partial data.
This commit is contained in:
10
index.js
10
index.js
@@ -171,10 +171,16 @@ function RedisClient (options, stream) {
|
||||
'The drain event listener is deprecated and will be removed in v.3.0.0.\n' +
|
||||
'If you want to keep on listening to this event please listen to the stream drain event directly.'
|
||||
);
|
||||
} else if (event === 'message_buffer' || event === 'pmessage_buffer' || event === 'messageBuffer' || event === 'pmessageBuffer' && !this.buffers) {
|
||||
} else if ((event === 'message_buffer' || event === 'pmessage_buffer' || event === 'messageBuffer' || event === 'pmessageBuffer') && !this.buffers && !this.message_buffers) {
|
||||
if (this.reply_parser.name !== 'javascript') {
|
||||
return this.warn(
|
||||
'You attached the ' + event + ' without the hiredis parser without the returnBuffers option set to true.\n' +
|
||||
'Please use the JavaScript parser or set the returnBuffers option to true to return buffers.'
|
||||
);
|
||||
}
|
||||
this.reply_parser.optionReturnBuffers = true;
|
||||
this.message_buffers = true;
|
||||
this.handle_reply = handle_detect_buffers_reply;
|
||||
this.reply_parser = create_parser(this);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
Reference in New Issue
Block a user