You've already forked node-redis
mirror of
https://github.com/redis/node-redis.git
synced 2025-08-09 00:22:08 +03:00
Fix parser regression
Add regression test Rename big_offset to big_str_size Fixes #924
This commit is contained in:
@@ -1,11 +1,17 @@
|
|||||||
Changelog
|
Changelog
|
||||||
=========
|
=========
|
||||||
|
|
||||||
|
## v.2.4.1 - 25 Nov, 2015
|
||||||
|
|
||||||
|
Bugfixes
|
||||||
|
|
||||||
|
- Fixed a js parser regression introduced in 2.4.0 ([@BridgeAR](https://github.com/BridgeAR))
|
||||||
|
|
||||||
## v.2.4.0 - 25 Nov, 2015
|
## v.2.4.0 - 25 Nov, 2015
|
||||||
|
|
||||||
Features
|
Features
|
||||||
|
|
||||||
- Added `tls` option to iniate a connection to a redis server behind a TLS proxy. Thanks ([@paddybyers](https://github.com/paddybyers))
|
- Added `tls` option to initiate a connection to a redis server behind a TLS proxy. Thanks ([@paddybyers](https://github.com/paddybyers))
|
||||||
- Added `prefix` option to auto key prefix any command with the provided prefix ([@luin](https://github.com/luin) & [@BridgeAR](https://github.com/BridgeAR))
|
- Added `prefix` option to auto key prefix any command with the provided prefix ([@luin](https://github.com/luin) & [@BridgeAR](https://github.com/BridgeAR))
|
||||||
- Added `url` option to pass the connection url with the options object ([@BridgeAR](https://github.com/BridgeAR))
|
- Added `url` option to pass the connection url with the options object ([@BridgeAR](https://github.com/BridgeAR))
|
||||||
- Added `client.duplicate([options])` to duplicate the current client and return a new one with the same options ([@BridgeAR](https://github.com/BridgeAR))
|
- Added `client.duplicate([options])` to duplicate the current client and return a new one with the same options ([@BridgeAR](https://github.com/BridgeAR))
|
||||||
|
@@ -6,7 +6,7 @@ function JavascriptReplyParser() {
|
|||||||
this.name = exports.name;
|
this.name = exports.name;
|
||||||
this._buffer = new Buffer(0);
|
this._buffer = new Buffer(0);
|
||||||
this._offset = 0;
|
this._offset = 0;
|
||||||
this._big_offset = 0;
|
this._big_str_size = 0;
|
||||||
this._chunks_size = 0;
|
this._chunks_size = 0;
|
||||||
this._buffers = [];
|
this._buffers = [];
|
||||||
this._type = 0;
|
this._type = 0;
|
||||||
@@ -53,7 +53,7 @@ JavascriptReplyParser.prototype._parseResult = function (type) {
|
|||||||
|
|
||||||
if (end + 2 > this._buffer.length) {
|
if (end + 2 > this._buffer.length) {
|
||||||
this._chunks_size = this._buffer.length - this._offset - 2;
|
this._chunks_size = this._buffer.length - this._offset - 2;
|
||||||
this._big_offset = packetHeader;
|
this._big_str_size = packetHeader;
|
||||||
throw new IncompleteReadBuffer('Wait for more data.');
|
throw new IncompleteReadBuffer('Wait for more data.');
|
||||||
}
|
}
|
||||||
// Set the offset to after the delimiter
|
// Set the offset to after the delimiter
|
||||||
@@ -85,17 +85,17 @@ JavascriptReplyParser.prototype._parseResult = function (type) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
JavascriptReplyParser.prototype.execute = function (buffer) {
|
JavascriptReplyParser.prototype.execute = function (buffer) {
|
||||||
if (this._chunks_size !== 0 && this._big_offset > this._chunks_size + buffer.length) {
|
if (this._chunks_size !== 0) {
|
||||||
this._buffers.push(buffer);
|
if (this._big_str_size > this._chunks_size + buffer.length) {
|
||||||
this._chunks_size += buffer.length;
|
this._buffers.push(buffer);
|
||||||
return;
|
this._chunks_size += buffer.length;
|
||||||
}
|
return;
|
||||||
if (this._buffers.length !== 0) {
|
}
|
||||||
this._buffers.unshift(this._offset === 0 ? this._buffer : this._buffer.slice(this._offset));
|
this._buffers.unshift(this._offset === 0 ? this._buffer : this._buffer.slice(this._offset));
|
||||||
this._buffers.push(buffer);
|
this._buffers.push(buffer);
|
||||||
this._buffer = Buffer.concat(this._buffers);
|
this._buffer = Buffer.concat(this._buffers);
|
||||||
this._buffers = [];
|
this._buffers = [];
|
||||||
this._big_offset = 0;
|
this._big_str_size = 0;
|
||||||
this._chunks_size = 0;
|
this._chunks_size = 0;
|
||||||
} else if (this._offset >= this._buffer.length) {
|
} else if (this._offset >= this._buffer.length) {
|
||||||
this._buffer = buffer;
|
this._buffer = buffer;
|
||||||
|
@@ -256,6 +256,23 @@ describe('parsers', function () {
|
|||||||
parser.execute(new Buffer('*1\r\n$4\r\ntest\r\n'));
|
parser.execute(new Buffer('*1\r\n$4\r\ntest\r\n'));
|
||||||
assert.strictEqual(reply_count, 3);
|
assert.strictEqual(reply_count, 3);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('regression test v.2.4.1', function () {
|
||||||
|
var parser = new Parser(true);
|
||||||
|
var reply_count = 0;
|
||||||
|
var entries = ['test test ', 'test test test test ', '1234'];
|
||||||
|
function check_reply(reply) {
|
||||||
|
assert.strictEqual(reply.toString(), entries[reply_count]);
|
||||||
|
reply_count++;
|
||||||
|
}
|
||||||
|
parser.send_reply = check_reply;
|
||||||
|
parser.execute(new Buffer('$10\r\ntest '));
|
||||||
|
assert.strictEqual(reply_count, 0);
|
||||||
|
parser.execute(new Buffer('test \r\n$20\r\ntest test test test \r\n:1234\r'));
|
||||||
|
assert.strictEqual(reply_count, 2);
|
||||||
|
parser.execute(new Buffer('\n'));
|
||||||
|
assert.strictEqual(reply_count, 3);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
Reference in New Issue
Block a user