Bug #17675
closedt3lib_div::validEmail does not allow '+' in localpart of mail address
0%
Description
class.t3lib_div.php provides the method validEmail() to check for validity of a given email address. Minor problem: The function does not accept plus-signs "+" in the localpart of email addresses; these are legal though and some people are using them.
(issue imported from #M6515)
Files
Updated by Christian Kuhn about 17 years ago
Digging into this topic I had to find out that RFC2822 also allows several other characters like "*" and "^" in the local-part of an address. (Section 3.2.4, 3.4.1).
Furthermore the "." is only valid if its not at the beginning or end of the local-part. The current regex also does not reflect this. And the plus-sign has (if used) sometimes only the meaning of a tag-mechanism for filtering.
There is a nice article at http://en.wikipedia.org/wiki/E-mail_address and especially for the regex-matching I found http://www.regular-expressions.info/email.html . Tons of other articles can be found on the net.
Your patch is correct so far, no question. I personally think (but that does not mean anything) a subset of the spec will suffice, most people don't use any special characters anyway (except . and -), so I would prefer to stick to the current implementation. A real change would have to come up with a quite complicated regex, and even then this would either be a monster or a subset of the spec.
Updated by Wolfgang Zenker about 17 years ago
I'm aware that the regex is far from perfect. I'm asking to add the '+' sign specifically because some of our users make use of the '+' for tagging of mailaddresses.
Updated by Christian Kuhn about 17 years ago
I have tested your patch on trunk (with the tipafriend ext) and will give you a +1 on reading and testing if you submit it.
Updated by Christian Kuhn over 15 years ago
Resolved as duplicate of #20285
t3lib_div::validEmail now uses native PHP filter in 4.3