Bug #17675
closed
t3lib_div::validEmail does not allow '+' in localpart of mail address
Added by Wolfgang Zenker over 16 years ago.
Updated over 5 years ago.
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
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.
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.
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.
Resolved as duplicate of #20285
t3lib_div::validEmail now uses native PHP filter in 4.3
- Status changed from Resolved to Closed
Also available in: Atom
PDF