Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix multi "empty" string separated by "," marked as valid emails #1507

Merged
merged 1 commit into from
Nov 22, 2018

Conversation

samsonasik
Copy link
Member

In Validation\FormatRules::valid_emails(), if we passed a string:

','

It previously checked as valid email, while empty string is not valid email. We need to check if the string separated by comma is an empty string or not. If empty, then return false early.

Checklist:

  • Securely signed commits
  • Unit testing, with >80% coverage

@jim-parry
Copy link
Contributor

Testing for ',' makes sense, but the FormatRules change doesn't seem to serve a point. If looking to eliminate a trim(...), then why not just

$email = trim($email);
return (empty($email)) ? false : $this->valid_email($email);

@samsonasik
Copy link
Member Author

It is in the loop, so it doesn't want to return early on non-empty email, so the code sample you gave will return "true" early even the passed email is valid, and next email is not valid.

@jim-parry
Copy link
Contributor

I see your point now :)

@jim-parry jim-parry merged commit 630b792 into codeigniter4:develop Nov 22, 2018
@samsonasik samsonasik deleted the valid-emails branch November 22, 2018 06:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants