Skip to content
This repository was archived by the owner on Jul 10, 2019. It is now read-only.

Commit ad2b6d1

Browse files
author
Felix Hammerl
committed
[WO-587] Explicitly include arbitrary headers in clearsigned regex
1 parent ec238a5 commit ad2b6d1

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

src/js/dao/email-dao.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -772,11 +772,11 @@ define(function(require) {
772772
/*
773773
* any content before/after the PGP block will be discarded,
774774
* "-----BEGIN/END (...)-----" must be at the start/end of a line,
775-
* after \n\n the signed payload begins,
775+
* after the hash (and possibly other) arbitrary headers, the signed payload begins,
776776
* the text is followed by a final \n and then the pgp signature begins
777777
* untrusted attachments and html is ignored
778778
*/
779-
var clearSignedMatch = /^-{5}BEGIN PGP SIGNED MESSAGE-{5}[\s\S]*\n\n([\s\S]*)\n-{5}BEGIN PGP SIGNATURE-{5}[\S\s]*-{5}END PGP SIGNATURE-{5}$/im.exec(body);
779+
var clearSignedMatch = /^-{5}BEGIN PGP SIGNED MESSAGE-{5}\nHash:[ ][^\n]+\n(?:[A-Za-z]+:[ ][^\n]+\n)*\n([\s\S]*)\n-{5}BEGIN PGP SIGNATURE-{5}[\S\s]*-{5}END PGP SIGNATURE-{5}$/im.exec(body);
780780
if (clearSignedMatch) {
781781
// PGP/INLINE signed
782782
message.signed = true;

test/unit/email-dao-test.js

+4-3
Original file line numberDiff line numberDiff line change
@@ -1010,9 +1010,10 @@ define(function(require) {
10101010
});
10111011

10121012
it('should read a signed pgp/inline from the device', function(done) {
1013-
var message, pt;
1013+
var message, pt, expected;
10141014

1015-
pt = '-----BEGIN PGP SIGNED MESSAGE-----\n\ntest6\n-----BEGIN PGP SIGNATURE----------END PGP SIGNATURE-----';
1015+
expected = 'Lorem ipsum Aliquip tempor veniam proident.\n\nafguab;igab;igubalw\n\nLorem ipsum Dolor sed irure sint in non.\n\n\n';
1016+
pt = '-----BEGIN PGP SIGNED MESSAGE-----\nHash: WTFHASH\n\n' + expected + '\n-----BEGIN PGP SIGNATURE----------END PGP SIGNATURE-----';
10161017
message = {
10171018
uid: uid,
10181019
from: [{
@@ -1036,7 +1037,7 @@ define(function(require) {
10361037
expect(err).to.not.exist;
10371038

10381039
expect(msg).to.equal(message);
1039-
expect(msg.body).to.equal('test6');
1040+
expect(msg.body).to.equal(expected);
10401041
expect(message.signed).to.be.true;
10411042
expect(message.signaturesValid).to.be.true;
10421043
expect(message.loadingBody).to.be.false;

0 commit comments

Comments
 (0)