Comparing version 0.1.11 to 0.1.12
@@ -207,3 +207,3 @@ "use strict"; | ||
this._endDataModeSequence = "\r\n.\r\n"; | ||
this._endDataModeSequenceRegEx = /\r\n\.\r\n|^\.\r\n/; | ||
this._endDataModeSequenceRegEx = /\r\n\.\r\n/; | ||
@@ -260,3 +260,3 @@ this.secureConnection = !!this.options.secureConnection; | ||
this._endDataModeSequence = "\r\n"+sequence+"\r\n"; | ||
this._endDataModeSequenceRegEx = new RegExp("\\r\\n" + sequence + "\\r\\n|^"+sequence+"\\r\\n"); | ||
this._endDataModeSequenceRegEx = new RegExp("\\r\\n" + sequence + "\\r\\n"); | ||
} | ||
@@ -343,18 +343,12 @@ }; | ||
var str = typeof chunk=="string"?chunk:chunk.toString("binary"), | ||
dataEndMatch, dataRemainderMatch, data, match; | ||
dataRemainderMatch, data; | ||
if(this._dataMode){ | ||
// prefix the incoming chunk with the remainder of the previous chunk | ||
str = this._remainder + str; | ||
if((dataEndMatch = str.match(/\r\n.*?$/))){ | ||
// if ther's a line that is not ended, keep it for later | ||
this._remainder = str.substr(dataEndMatch.index); | ||
str = str.substr(0, dataEndMatch.index); | ||
}else{ | ||
this._remainder = ""; | ||
} | ||
this._remainder = ""; | ||
// check if a data end sequence is found from the data | ||
if((dataRemainderMatch = (str+this._remainder).match(this._endDataModeSequenceRegEx))){ | ||
str = str + this._remainder; | ||
if((dataRemainderMatch = str.match(this._endDataModeSequenceRegEx))){ | ||
// if the sequence is not on byte 0 emit remaining data | ||
@@ -367,3 +361,2 @@ if(dataRemainderMatch.index){ | ||
// emit data ready | ||
this._remainder = ""; | ||
this.emit("ready"); | ||
@@ -376,13 +369,10 @@ this._dataMode = false; | ||
// end sequence - if so, cut it off and save it to the remainder | ||
str = str + this._remainder; | ||
this._remainder= ""; | ||
for(var i = Math.min(this._endDataModeSequence.length-1, str.length); i>0; i--){ | ||
match = this._endDataModeSequence.substr(0, i); | ||
if(str.substr(-match.length) == match){ | ||
this._remainder = str.substr(-match.length); | ||
str = str.substr(0, str.length - match.length); | ||
if(str.substr(-i) == this._endDataModeSequence.substr(0, i)){ | ||
this._remainder = str.substr(-i); | ||
str = str.substr(0, str.length - i); | ||
} | ||
} | ||
// if there's some data leht, emit it | ||
// if there's some data left, emit it | ||
if(str.length){ | ||
@@ -495,2 +485,2 @@ data = new Buffer(str, "binary"); | ||
this._destroy(); | ||
}; | ||
}; |
{ | ||
"name": "rai", | ||
"description": "Request-Answer-Interface for generating text based command servers (SMTP, POP etc)", | ||
"version": "0.1.11", | ||
"version": "0.1.12", | ||
"author" : "Andris Reinman", | ||
@@ -31,2 +31,2 @@ "maintainers":[ | ||
"keywords": ["servers", "text-based"] | ||
} | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
30047
612