From 172855a8e911bab6eb51d0cf321db2db6ae14313 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Obernd=C3=B6rfer?= Date: Fri, 16 May 2014 19:08:29 +0200 Subject: [PATCH] Redefine Regex for blank line after armor header. This fixes an issue with truncated blank lines at the beginning of cleartext signed messages. --- src/encoding/armor.js | 3 ++- test/general/armor.js | 8 +++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/encoding/armor.js b/src/encoding/armor.js index 476b04bb..13ea2d0a 100644 --- a/src/encoding/armor.js +++ b/src/encoding/armor.js @@ -211,7 +211,8 @@ function createcrc24(input) { * and an attribute "body" containing the body. */ function splitHeaders(text) { - var reEmptyLine = /^\s*\n/m; + // empty line with whitespace characters + var reEmptyLine = /^[ \f\r\t\u00a0\u2000-\u200a\u202f\u205f\u3000]*\n/m; var headers = ''; var body = text; diff --git a/test/general/armor.js b/test/general/armor.js index e45a9d88..205766eb 100644 --- a/test/general/armor.js +++ b/test/general/armor.js @@ -84,7 +84,7 @@ describe("ASCII armor", function() { var msg = ['-----BEGIN PGP SIGNED MESSAGE-----', 'Hash: SHA1', - '\u000b\u00a0', + ' \f\r\t\u00a0\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000', 'sign this', '-----BEGIN PGP SIGNATURE-----', 'Version: GnuPG v2.0.22 (GNU/Linux)', @@ -183,6 +183,12 @@ describe("ASCII armor", function() { expect(result.keys[0]).to.be.an.instanceof(openpgp.key.Key); }); + it('Do not filter blank lines after header', function () { + var msg = getArmor(['Hash: SHA1', '']); + msg = openpgp.cleartext.readArmored(msg); + expect(msg.text).to.equal('\r\nsign this'); + }); + });