configurable max uid length | close #724

This commit is contained in:
Tom James Holub 2018-06-30 04:35:08 +00:00
parent c7a65ccd16
commit 35260cb5db
2 changed files with 10 additions and 1 deletions

View File

@ -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
};

View File

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