Ignoring if workerinfo['admin'] is None.
Details
Diff Detail
- Repository
- rZORG LLVM Github Zorg
Event Timeline
Thanks, Dmitry!
How about using something like email.utils.parseaddr instead of a regex to parse email addresses?
It would be also nice to support multiple owners of a single worker. Not necessarily a subject of this patch, though.
I have updated the patch to extract all e-mail addresses in the admin info.
Note the dot at the end of the e-mail address is alloved in case of the admin info like Name1 <user1@domain.com>, Name2 user2@domain.com.
email.utils.parseaddr keeps the dot at the end too. It seems email.utils.parseaddr uses a similar regex.
If you insist on using regex, could you use something like ([-!#-'*+/-9=?A-Z^-~]+(\.[-!#-'*+/-9=?A-Z^-~]+)*|\"([]!#-[^-~ \t]|(\\[\t -~]))+\")@([-!#-'*+/-9=?A-Z^-~]+(\.[-!#-'*+/-9=?A-Z^-~]+)*|\[[\t -Z^-~]*]) or even more RFC 5322 compliant regex, please? That also would handle terminating dots and such for you.
And it might worth logging the fact that valid admin info is missing. What do you think?
I have updated the patch with the suggested regex.
I have tested it here https://regex101.com/r/CZN3Mg/1
The e-mail "us\er2"@domain.com looks strange.
I think adding the logging that the admin info is incorrect here is bad idea.
Note this method will be called on every authentication and it checks all workers.
We will get a lot of spam if few workers have no admin info or a valid e-mail in the admin info.
LGTM.
Admin info could change only at a worker connect handshake. We shall consider caching emails rather than parsing every time there is a use. Not a subject of this patch, though.
The e-mail "us\er2"@domain.com looks strange.
According to RFC 5322 that email is valid, unless I'm missing something. Here is the relevant quote from RFC:
addr-spec = local-part "@" domain local-part = dot-atom / quoted-string / obs-local-part ... the quote and backslash characters may appear in a quoted-string so long as they appear as a quoted-pair.