mirror of
https://github.com/openpgpjs/openpgpjs.git
synced 2026-03-11 19:24:48 +00:00
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.
This commit is contained in:
@@ -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);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user