Commit 678cf342 by pupi1985

Fix mismatch between Q2A and PHPMailer email validation algorithm

parent 7ed3f6a0
......@@ -135,6 +135,7 @@ function qa_send_email($params)
require_once QA_INCLUDE_DIR . 'vendor/PHPMailer/PHPMailerAutoload.php';
PHPMailer::$validator = 'php';
$mailer = new PHPMailer();
$mailer->CharSet = 'utf-8';
......
......@@ -736,7 +736,7 @@ function qa_email_validate($email)
{
if (qa_to_override(__FUNCTION__)) { $args=func_get_args(); return qa_call_override(__FUNCTION__, $args); }
return preg_match("/^[\-\!\#\$\%\&\'\*\+\/\=\?\_\`\{\|\}\~a-zA-Z0-9\.\^]+\@[a-zA-Z0-9\-]+\.[a-zA-Z0-9\.\-]+$/", $email) === 1;
return (bool)filter_var($email, FILTER_VALIDATE_EMAIL);
}
......
......@@ -126,13 +126,14 @@ class UtilStringTest extends PHPUnit_Framework_TestCase
$goodEmails = array(
'hello@example.com',
'q.a@question2answer.org',
'example@newdomain.app'
'example@newdomain.app',
);
$badEmails = array(
'nobody@nowhere',
'pokémon@example.com',
'email @ with spaces',
'some random string',
'dotbeforeat.@email.com',
);
foreach ($goodEmails as $email) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment