Skip to content

Commit 5d08132

Browse files
author
Ruben Bridgewater
committed
Fix: do not stop parsing a chunk if the first character is a line break
Add changelog entry
1 parent 9b3b090 commit 5d08132

File tree

3 files changed

+7
-8
lines changed

3 files changed

+7
-8
lines changed

changelog.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
Changelog
22
=========
33

4+
Bugfixes
5+
6+
- Fixed a js parser error that could result in a timeout ([@BridgeAR](https://github.com/BridgeAR))
7+
48
## v.2.2.5 - 18 Oct, 2015
59

610
Bugfixes

lib/parsers/javascript.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,9 +117,7 @@ JavascriptReplyParser.prototype.execute = function (buffer) {
117117
offset = this._offset - 1;
118118

119119
this.send_reply(this._parseResult(type));
120-
} else if (type === 10 || type === 13) {
121-
break;
122-
} else {
120+
} else if (type !== 10 && type !== 13) {
123121
var err = new Error('Protocol error, got "' + String.fromCharCode(type) + '" as reply type byte');
124122
this.send_error(err);
125123
}

test/parser.spec.js

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ describe('parsers', function () {
5555
return done();
5656
});
5757

58-
it('line breaks in the beginning', function (done) {
58+
it('line breaks in the beginning of the last chunk', function (done) {
5959
var parser = new Parser();
6060
var reply_count = 0;
6161
function check_reply(reply) {
@@ -68,10 +68,7 @@ describe('parsers', function () {
6868
parser.execute(new Buffer('*1\r\n*1\r\n$1\r\na'));
6969

7070
parser.execute(new Buffer('\r\n*1\r\n*1\r'));
71-
parser.execute(new Buffer('\n$1\r\na\r\n'));
72-
73-
parser.execute(new Buffer('*1\r\n*1\r\n'));
74-
parser.execute(new Buffer('$1\r\na\r\n'));
71+
parser.execute(new Buffer('\n$1\r\na\r\n*1\r\n*1\r\n$1\r\na\r\n'));
7572

7673
assert.equal(reply_count, 3, "check reply should have been called three times");
7774
return done();

0 commit comments

Comments
 (0)