Skip to content

Email Validation func is Improper #351

@mohammed90

Description

@mohammed90

[REQUIRED] Step 2: Describe your environment

  • Operating System version: Mac OS
  • Firebase SDK version: v3.12.0
  • Library version: v3.12.0 (? not sure which library do you mean here)
  • Firebase Product: auth (auth, database, storage, etc)

[REQUIRED] Step 3: Describe the problem

Steps to reproduce:

The email validation func checks if the split over @ results in 2 parts:

if parts := strings.Split(email, "@"); len(parts) != 2 || parts[0] == "" || parts[1] == "" {
return fmt.Errorf("malformed email string: %q", email)
}

But this risks rejecting valid email address. These are all valid email addresses:

which the library will reject. The recommendation per Stavros Korokithakis is to check if there's an @ symbol and try to send an email to it. If they click the validation link, then it's a real address. So replace the prior snippet with:

Relevant Code:

Current code:

if parts := strings.Split(email, "@"); len(parts) != 2 || parts[0] == "" || parts[1] == "" {
return fmt.Errorf("malformed email string: %q", email)
}

Suggested replacement:

if !strings.Contains(email, "@") {
	return fmt.Errorf("malformed email string: %q", email)
}

References:

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions