support split checksum where body and checksum are on the same line

This commit is contained in:
Sanjana Rajan 2017-06-27 16:41:53 -07:00
parent ddf6eb5783
commit a7702a74d3

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 };