diff --git a/system/Validation/FormatRules.php b/system/Validation/FormatRules.php index e54c78a3c008..e0e527215bf9 100644 --- a/system/Validation/FormatRules.php +++ b/system/Validation/FormatRules.php @@ -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; } diff --git a/tests/system/Validation/FormatRulesTest.php b/tests/system/Validation/FormatRulesTest.php index bd5c4c9dc149..4cba651aa8c0 100644 --- a/tests/system/Validation/FormatRulesTest.php +++ b/tests/system/Validation/FormatRulesTest.php @@ -241,6 +241,10 @@ public function emailsProvider() null, false, ], + [ + ',', + false, + ], ]; }