From 35260cb5dbc99970b938af20e71f0056a8285e05 Mon Sep 17 00:00:00 2001 From: Tom James Holub Date: Sat, 30 Jun 2018 04:35:08 +0000 Subject: [PATCH] configurable max uid length | close #724 --- src/config/config.js | 8 +++++++- src/util.js | 3 +++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/config/config.js b/src/config/config.js index 630c30a3..d519575e 100644 --- a/src/config/config.js +++ b/src/config/config.js @@ -167,5 +167,11 @@ export default { * @memberof module:config * @property {String} node_store */ - node_store: "./openpgp.store" + node_store: "./openpgp.store", + /** + * Max userid string length (used for parsing) + * @memberof module:config + * @property {Integer} max_userid_length + */ + max_userid_length: 1024 * 5 }; diff --git a/src/util.js b/src/util.js index 4f771231..a282ab8f 100644 --- a/src/util.js +++ b/src/util.js @@ -591,6 +591,9 @@ export default { * Parse user id. */ parseUserId: function(userid) { + if(userid.length > config.max_userid_length) { + throw new Error('User id string is too long'); + } try { const [{ phrase: name, address: email, comment }] = rfc2822.parse(userid); return { name, email, comment: comment.replace(/^\(|\)$/g, '') };