From 109f8a5d2052dbf31839dd7ca66dfcf2650d823d Mon Sep 17 00:00:00 2001 From: Sanjana Rajan Date: Wed, 14 Dec 2016 12:38:01 -0800 Subject: [PATCH] don't allow leading spaces in user id --- src/openpgp.js | 5 ++++- src/util.js | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/openpgp.js b/src/openpgp.js index 0a5cacf3..02f69e2a 100644 --- a/src/openpgp.js +++ b/src/openpgp.js @@ -391,7 +391,10 @@ function formatUserIds(options) { if (!util.isString(id.name) || (id.email && !util.isEmailAddress(id.email))) { throw new Error('Invalid user id format'); } - return id.name + ' <' + id.email + '>'; + if (id.name) { + id.name += ' '; + } + return id.name + '<' + id.email + '>'; }); return options; } diff --git a/src/util.js b/src/util.js index 32f22445..b329d84b 100644 --- a/src/util.js +++ b/src/util.js @@ -51,7 +51,7 @@ export default { if (!this.isString(data)) { return false; } - return / $/.test(data); + return /$/.test(data); }, /**