Merge pull request #557 from openpgpjs/decode_single_line

allow body + checksum on same line in splitChecksum
This commit is contained in:
Bart Butler 2017-06-27 23:47:03 -07:00 committed by GitHub
commit 402e26d98c

View File

@ -239,15 +239,14 @@ function verifyHeaders(headers) {
* and an attribute "checksum" containing the checksum. * and an attribute "checksum" containing the checksum.
*/ */
function splitChecksum(text) { function splitChecksum(text) {
var reChecksumStart = /^=/m;
var body = text; var body = text;
var checksum = ""; var checksum = "";
var matchResult = reChecksumStart.exec(text); var lastEquals = text.lastIndexOf("=");
if (matchResult !== null) { if (lastEquals >= 0) {
body = text.slice(0, matchResult.index); body = text.slice(0, lastEquals);
checksum = text.slice(matchResult.index + 1); checksum = text.slice(lastEquals + 1);
} }
return { body: body, checksum: checksum }; return { body: body, checksum: checksum };