improved armor behavior - trailing newline

This commit is contained in:
Tom James Holub 2017-07-21 15:35:27 -07:00
parent 80742bdfbe
commit 841b03d6cd

View File

@ -246,10 +246,7 @@ function splitChecksum(text) {
if (lastEquals >= 0) {
body = text.slice(0, lastEquals);
checksum = text.slice(lastEquals + 1);
if (checksum.substr(0, 6) === '\n-----') {
checksum = ''; // missing armor checksum
}
checksum = text.slice(lastEquals + 1).trim().substr(0, 4);
}
return { body: body, checksum: checksum };
@ -271,6 +268,7 @@ function dearmor(text) {
var type = getType(text);
text = text.trim() + "\n";
var splittext = text.split(reSplit);
// IE has a bug in split with a re. If the pattern matches the beginning of the
@ -312,8 +310,6 @@ function dearmor(text) {
checksum = sig_sum.checksum;
}
checksum = checksum.substr(0, 4);
if (!verifyCheckSum(result.data, checksum) && (checksum || config.checksum_required)) {
// will NOT throw error if checksum is empty AND checksum is not required (GPG compatibility)
throw new Error("Ascii armor integrity check on message failed: '" + checksum + "' should be '" +