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, '') };