Skip to content

EmailValidator should use filter_var in strict mode if Egulias library is missing #25674

@ebuildy

Description

@ebuildy
Q A
Bug report? no
Feature request? yes
BC Break report? no
RFC? yes/no
Symfony version 4.0.0

Egulias\EmailValidator\EmailValidator is not really perfect (toto@toto.___c is valid whereas it's not for HTML5 or filter_var), so I propose to use filter_var with FILTER_VALIDATE_EMAIL if Egulias is not installed:

EmailValidator:

if (!class_exists('\Egulias\EmailValidator\EmailValidator')) {
                if (filter_var($value, FILTER_VALIDATE_EMAIL) === false) {
                    $this->context->buildViolation($constraint->message)
                        ->setParameter('{{ value }}', $this->formatValue($value))
                        ->setCode(Email::INVALID_FORMAT_ERROR)
                        ->addViolation();

                    return;
                }
            }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions