Handle long keyid

This commit is contained in:
nemunaire 2021-09-19 15:42:22 +02:00
parent 7002341583
commit 5d2d4ff451

View File

@ -9,16 +9,17 @@ LOGIN_FIELD = 2
EMAILADDR_FIELD = 3
def check(cnt, file):
def check(cnt, *files):
data, uname = cnt
username, address = parseaddr(uname)
with open(file, encoding='utf-8') as fd:
people = csv.reader(fd)
for p in people:
if address.lower() == p[EMAILADDR_FIELD].lower() or uname.lower().find(p[LOGIN_FIELD].lower()) >= 0 or username.lower().replace(" ", "").find(p[LASTNAME_FIELD].lower().replace(" ", "")) >= 0 and username.lower().find(p[FIRSTNAME_FIELD].lower()) >= 0:
yield MailTest("Recognized as %s: %s %s." % (p[LOGIN_FIELD], p[FIRSTNAME_FIELD], p[LASTNAME_FIELD]))
yield data, p[LOGIN_FIELD]
return
for file in files:
with open(file, encoding='utf-8') as fd:
people = csv.reader(fd)
for p in people:
if address.lower() == p[EMAILADDR_FIELD].lower() or uname.lower().find(p[LOGIN_FIELD].lower()) >= 0 or username.lower().replace(" ", "").find(p[LASTNAME_FIELD].lower().replace(" ", "")) >= 0 and username.lower().find(p[FIRSTNAME_FIELD].lower()) >= 0:
yield MailTest("Recognized as %s: %s %s." % (p[LOGIN_FIELD], p[FIRSTNAME_FIELD], p[LASTNAME_FIELD]))
yield data, p[LOGIN_FIELD]
return
yield MailTest("The username of your key is not explicit, I can't find you.", 1)