Skip to content

Commit

Permalink
Merge pull request #1507 from samsonasik/valid-emails
Browse files Browse the repository at this point in the history
Fix multi "empty" string separated by "," marked as valid emails
  • Loading branch information
jim-parry authored Nov 22, 2018
2 parents bf09ee5 + d94040b commit 630b792
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
8 changes: 7 additions & 1 deletion system/Validation/FormatRules.php
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,13 @@ public function valid_emails(string $str = null): bool

foreach (explode(',', $str) as $email)
{
if (trim($email) !== '' && $this->valid_email(trim($email)) === false)
$email = trim($email);
if ($email === '')
{
return false;
}

if ($this->valid_email($email) === false)
{
return false;
}
Expand Down
4 changes: 4 additions & 0 deletions tests/system/Validation/FormatRulesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,10 @@ public function emailsProvider()
null,
false,
],
[
',',
false,
],
];
}

Expand Down

0 comments on commit 630b792

Please sign in to comment.