mirror of
https://github.com/openpgpjs/openpgpjs.git
synced 2026-03-03 16:00:26 +00:00
Fix removing whitespace from the last line of cleartext signed messages
Also, move normalizing line endings and removing whitespace to util functions
This commit is contained in:
21
src/util.js
21
src/util.js
@@ -574,5 +574,26 @@ export default {
|
||||
return false;
|
||||
}
|
||||
return /</.test(data) && />$/.test(data);
|
||||
},
|
||||
|
||||
/**
|
||||
* Normalize line endings to \r\n
|
||||
*/
|
||||
canonicalizeEOL: function(text) {
|
||||
return text.replace(/\r\n/g, "\n").replace(/\r/g, "\n").replace(/\n/g, "\r\n");
|
||||
},
|
||||
|
||||
/**
|
||||
* Convert line endings from canonicalized \r\n to native \n
|
||||
*/
|
||||
nativeEOL: function(text) {
|
||||
return text.replace(/\r\n/g, "\n");
|
||||
},
|
||||
|
||||
/**
|
||||
* Remove trailing spaces and tabs from each line
|
||||
*/
|
||||
removeTrailingSpaces: function(text) {
|
||||
return text.replace(/[ \t]+$/mg, "");
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user