From 68d1b5a35c9e2446ea2011b859d804ddfc5523a0 Mon Sep 17 00:00:00 2001 From: Harry Marr Date: Tue, 1 Dec 2015 21:13:29 +0000 Subject: [PATCH] Handle carriage-return only newlines Newlines are normalised to \r\n, but that previously assumed that only \r\n and \n newline characters could be used. Even though \r newlines are rarely used in the wild, it's be helpful to support them. Currently, they're just removed entirely. --- src/packet/literal.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/packet/literal.js b/src/packet/literal.js index 5636e266..363eb4ea 100644 --- a/src/packet/literal.js +++ b/src/packet/literal.js @@ -48,7 +48,7 @@ export default function Literal() { */ Literal.prototype.setText = function(text) { // normalize EOL to \r\n - text = text.replace(/\r/g, '').replace(/\n/g, '\r\n'); + text = text.replace(/\r\n/g, '\n').replace(/\r/g, '\n').replace(/\n/g, '\r\n'); // encode UTF8 this.data = this.format === 'utf8' ? util.str2Uint8Array(util.encode_utf8(text)) : util.str2Uint8Array(text); };