Merge pull request #725 from FlowCrypt/master

configurable max uid length | close #724
This commit is contained in:
Sanjana Rajan 2018-07-02 11:44:38 +02:00 committed by GitHub
commit b56afca063
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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, '') };