Skip to content

Commit 630b792

Browse files
authored
Merge pull request #1507 from samsonasik/valid-emails
Fix multi "empty" string separated by "," marked as valid emails
2 parents bf09ee5 + d94040b commit 630b792

2 files changed

Lines changed: 11 additions & 1 deletion

File tree

system/Validation/FormatRules.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,13 @@ public function valid_emails(string $str = null): bool
294294

295295
foreach (explode(',', $str) as $email)
296296
{
297-
if (trim($email) !== '' && $this->valid_email(trim($email)) === false)
297+
$email = trim($email);
298+
if ($email === '')
299+
{
300+
return false;
301+
}
302+
303+
if ($this->valid_email($email) === false)
298304
{
299305
return false;
300306
}

tests/system/Validation/FormatRulesTest.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,10 @@ public function emailsProvider()
241241
null,
242242
false,
243243
],
244+
[
245+
',',
246+
false,
247+
],
244248
];
245249
}
246250

0 commit comments

Comments
 (0)