Skip to content

Commit eb12cd7

Browse files
Add dirty fix for \r\n handling
1 parent 95eedee commit eb12cd7

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

lib/InputStream.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,10 @@ InputStream.prototype = {
2424
if(this.start >= this.data.length) {
2525
return InputStream.EOF;
2626
}
27-
return this.data[this.start++];
27+
var ch = this.data[this.start++];
28+
if (ch === '\r')
29+
ch = '\n';
30+
return ch;
2831
},
2932
advance: function(amount) {
3033
this.start += amount;
@@ -61,7 +64,7 @@ InputStream.prototype = {
6164
} else if(m = new RegExp(re + (this.eof ? "|$" : "")).exec(s)) {
6265
var t = this.data.slice(this.start, this.start + m.index);
6366
this.advance(m.index);
64-
return t.toString();
67+
return t.replace(/\r/g, '\n').replace(/\n{2,}/g, '\n');
6568
} else {
6669
throw InputStream.DRAIN;
6770
}

0 commit comments

Comments
 (0)