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

Fix: do not stop parsing a chunk if the first character is a line break

Add changelog entry
This commit is contained in:
Ruben Bridgewater
2015-10-27 11:13:43 +01:00
parent 9b3b090119
commit 5d08132f7c
3 changed files with 7 additions and 8 deletions

View File

@@ -1,6 +1,10 @@
Changelog
=========
Bugfixes
- Fixed a js parser error that could result in a timeout ([@BridgeAR](https://github.com/BridgeAR))
## v.2.2.5 - 18 Oct, 2015
Bugfixes

View File

@@ -117,9 +117,7 @@ JavascriptReplyParser.prototype.execute = function (buffer) {
offset = this._offset - 1;
this.send_reply(this._parseResult(type));
} else if (type === 10 || type === 13) {
break;
} else {
} else if (type !== 10 && type !== 13) {
var err = new Error('Protocol error, got "' + String.fromCharCode(type) + '" as reply type byte');
this.send_error(err);
}

View File

@@ -55,7 +55,7 @@ describe('parsers', function () {
return done();
});
it('line breaks in the beginning', function (done) {
it('line breaks in the beginning of the last chunk', function (done) {
var parser = new Parser();
var reply_count = 0;
function check_reply(reply) {
@@ -68,10 +68,7 @@ describe('parsers', function () {
parser.execute(new Buffer('*1\r\n*1\r\n$1\r\na'));
parser.execute(new Buffer('\r\n*1\r\n*1\r'));
parser.execute(new Buffer('\n$1\r\na\r\n'));
parser.execute(new Buffer('*1\r\n*1\r\n'));
parser.execute(new Buffer('$1\r\na\r\n'));
parser.execute(new Buffer('\n$1\r\na\r\n*1\r\n*1\r\n$1\r\na\r\n'));
assert.equal(reply_count, 3, "check reply should have been called three times");
return done();