Alternately, we could copy Moodle (again) and use a really liberal regex. Moodle 3.1 uses this one, which is nearly unchanged from 2001! The most recent functional update to it was in 2006, when it was changed to reject email addresses where the alias ends in a ".".
Basically, this regex checks for a list of acceptable characters for the alias, a "@", and a list of acceptable characters for the domain that includes at least one "." /** * Validates an email to make sure it makes sense. * * @param string $address The email address to validate. * @return boolean */ function validate_email($address) { return (preg_match('#^[-!\#$%&\'*+\\/0-9=?A-Z^_`a-z{|}~]+'. '(\.[-!\#$%&\'*+\\/0-9=?A-Z^_`a-z{|}~]+)*'. '@'. '[-!\#$%&\'*+\\/0-9=?A-Z^_`a-z{|}~]+\.'. '[-!\#$%&\'*+\\./0-9=?A-Z^_`a-z{|}~]+$#', $address)); } -- You received this bug notification because you are a member of Mahara Contributors, which is subscribed to Mahara. Matching subscriptions: Subscription for all Mahara Contributors -- please ask on #mahara-dev or mahara.org forum before editing or unsubscribing it! https://bugs.launchpad.net/bugs/1615280 Title: Email validation bug (long domains) Status in Mahara: In Progress Status in Mahara 15.04 series: In Progress Status in Mahara 15.10 series: In Progress Status in Mahara 16.04 series: In Progress Status in Mahara 16.10 series: In Progress Bug description: This one has existed since 2006, but only become an issue with the opening up of TLDs over the past few years. (https://en.wikipedia.org/wiki/List_of_Internet_top-level_domains) Currently the email validation in pieform limits the TLD to between 2-4 characters (see pieform_rule_email() in htdocs/lib/pieforms/pieform/rules/email.php.) That means people from .horse, for example, can't register. Changing the regex fixed my immediate problem, haven't tested how the other email validation points react. They use FILTER_VALIDATE_EMAIL and PHPMailer::ValidateAddress, so might be better. To manage notifications about this bug go to: https://bugs.launchpad.net/mahara/+bug/1615280/+subscriptions _______________________________________________ Mailing list: https://launchpad.net/~mahara-contributors Post to : mahara-contributors@lists.launchpad.net Unsubscribe : https://launchpad.net/~mahara-contributors More help : https://help.launchpad.net/ListHelp