configurable max uid length | close #724
This commit is contained in:
parent
c7a65ccd16
commit
35260cb5db
|
@ -167,5 +167,11 @@ export default {
|
||||||
* @memberof module:config
|
* @memberof module:config
|
||||||
* @property {String} node_store
|
* @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
|
||||||
};
|
};
|
||||||
|
|
|
@ -591,6 +591,9 @@ export default {
|
||||||
* Parse user id.
|
* Parse user id.
|
||||||
*/
|
*/
|
||||||
parseUserId: function(userid) {
|
parseUserId: function(userid) {
|
||||||
|
if(userid.length > config.max_userid_length) {
|
||||||
|
throw new Error('User id string is too long');
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
const [{ phrase: name, address: email, comment }] = rfc2822.parse(userid);
|
const [{ phrase: name, address: email, comment }] = rfc2822.parse(userid);
|
||||||
return { name, email, comment: comment.replace(/^\(|\)$/g, '') };
|
return { name, email, comment: comment.replace(/^\(|\)$/g, '') };
|
||||||
|
|
Loading…
Reference in New Issue
Block a user