Skip to content
Snippets Groups Projects
Commit 57e6e33c authored by Radko Krkoš's avatar Radko Krkoš Committed by Pavel Kácha
Browse files

Server: Fix requestor e-mail validation


* No longer silently accept pattern 'a@b@c', otherwise stay compatibile.
* Valid patterns are: 'user@fqdn', '<user@fqdn>', 'user <user@fqdn>',
  'user surname <user@fqdn>', no Unicode support, multiple e-mails
  separated by comma are allowed.
* Replace email.utils.parseaddr() with extended regular expression.
* Remove import email.utils as no other users exist.

Signed-off-by: default avatarPavel Kácha <ph@cesnet.cz>
parent 736be875
No related branches found
No related tags found
No related merge requests found
......@@ -14,7 +14,6 @@ import logging
import logging.handlers
import json
import re
import email.utils
from traceback import format_tb
from collections import namedtuple
from time import sleep
......@@ -1466,9 +1465,8 @@ def modify_client(**kwargs):
return allowed.match(nsid)
def isValidEmail(mail):
mails = (email.utils.parseaddr(m) for m in mail.split(","))
allowed = re.compile(r"^[a-zA-Z0-9_.%!+-]+@[a-zA-Z0-9-.]+$") # just basic check
valid = (allowed.match(ms[1]) for ms in mails)
allowed = re.compile(r"(^[a-zA-Z0-9_ .%!+-]*(?=<.*>))?(^|(<(?=.*(>))))[a-zA-Z0-9_.%!+-]+@[a-zA-Z0-9-.]+\4?$") # just basic check
valid = (allowed.match(ms.strip())for ms in mail.split(','))
return all(valid)
def isValidID(id):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment