[2.0.12] Email invalid when using new top domains due to length limitation

Started by APike, October 30, 2016, 07:02:38 AM

Previous topic - Next topic

APike

I seem to have found a minor bug in the email validation as it's not accepting top domain such as .systems it looks like the TLD have been capped to 6 characters.

Version of SMF 2.0.12
configuration:
- theme: default
- mods: none
- no extra language packs

Server soft:
- Apache 2.4.23
- PHP 7.0.9
- MariaDB 10.1.16

Error happened when entering an email on setup and on user modification (Profile-Modify.php)
Line 2977 - Function profileValidateEmail

error line:2977
Code (php) Select
if (preg_match('~^[0-9A-Za-z=_+\-/][0-9A-Za-z=_\'+\-/\.]*@[\w\-]+(\.[\w\-]+)*(\.[\w]{2,6})$~', $email) == 0)
recommended change:
Line: 2977
Code (php) Select
if (preg_match('~^[0-9A-Za-z=_+\-/][0-9A-Za-z=_\'+\-/\.]*@[\w\-]+(\.[\w\-]+)*(\.[\w]{2,15})$~', $email) == 0)


d3vcho

"Greeting Death as an old friend, they departed this life as equals"


nend

Looks like one got missed.

Also you can use
if(!filter_var($email, FILTER_VALIDATE_EMAIL))

Only reason it is done with regex is due to PHP 4 support.  ;)

Arantor

filter_var allows things that the regex does not, e.g. arantor@localhost

Advertisement: