Unverified Commit c2d4be56 by Scott Committed by GitHub

Merge pull request #773 from pupi1985/patch-135

Fix mismatch between Q2A and PHPMailer email validation algorithm
parents 9b71a5c2 678cf342
...@@ -135,6 +135,7 @@ function qa_send_email($params) ...@@ -135,6 +135,7 @@ function qa_send_email($params)
require_once QA_INCLUDE_DIR . 'vendor/PHPMailer/PHPMailerAutoload.php'; require_once QA_INCLUDE_DIR . 'vendor/PHPMailer/PHPMailerAutoload.php';
PHPMailer::$validator = 'php';
$mailer = new PHPMailer(); $mailer = new PHPMailer();
$mailer->CharSet = 'utf-8'; $mailer->CharSet = 'utf-8';
......
...@@ -736,7 +736,7 @@ function qa_email_validate($email) ...@@ -736,7 +736,7 @@ function qa_email_validate($email)
{ {
if (qa_to_override(__FUNCTION__)) { $args=func_get_args(); return qa_call_override(__FUNCTION__, $args); } 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 ...@@ -126,13 +126,14 @@ class UtilStringTest extends PHPUnit_Framework_TestCase
$goodEmails = array( $goodEmails = array(
'hello@example.com', 'hello@example.com',
'q.a@question2answer.org', 'q.a@question2answer.org',
'example@newdomain.app' 'example@newdomain.app',
); );
$badEmails = array( $badEmails = array(
'nobody@nowhere', 'nobody@nowhere',
'pokémon@example.com', 'pokémon@example.com',
'email @ with spaces', 'email @ with spaces',
'some random string', 'some random string',
'dotbeforeat.@email.com',
); );
foreach ($goodEmails as $email) { 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