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:
Daniel Huigens
2018-04-19 13:34:28 +02:00
parent 4e204d7331
commit ebeedd3443
4 changed files with 28 additions and 5 deletions

View File

@@ -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, "");
}
};