buildbot/buildbot — pull request #885 by olof (2013-09-19 20:41:43+00:00)
Title: buildbot.status.mail: improve email address regexp

The previous email regexp contained some flaws; the intentions of the regexp and the implemention had some gaps that would make it hard to rely on.

This rewrite should match any valid email address, but it does not give any guarantees that what it matches is a valid address. An increased level of complexity is (hopefully) compensated by a comment explaining the reasoning behind the regexp. This is accompanied by unit tests; you are encouraged to add any corner case addresses in either the test for valid or invalid addresses.

---

Using regular expressions for parsing email addresses can be tricky, http://www.ex-parrot.com/~pdw/Mail-RFC822-Address.html. :-) From the original regexp, it wasn't completely clear what it would match and what it wouldn't match. Some surprising addresses were accepted! But, as I write in the comment, it's more important to not reject a valid address than it is to reject an invalid address (that would be handled by the MTA later anyways).

The main purpose of this change is to make it clear what kind of strings the regexp is expected to be applied on, the actual regexp is very much up for debate.