Skip to content

[Validator] Email validation false-positive due to relative host #28665

Closed
@vudaltsov

Description

@vudaltsov

Symfony version(s) affected: any?

Description
As warned in the comment to checkdnsrr() docs, one should pass a fully qualified domain name to get correct results, i.e. symfony.com. instead of symfony.com

99.9% of the time users do not put a dot at the end of their email which leads to incorrect checks.

Possible Solution without breaking BC

  1. Add a config value framework.validation.make_host_absolute = null (like framework.validation.make_host_absolute). If not set explicitly to true or false a deprecation is shown: Not setting a value explicitly is deprecated. Will be true by default since 5.0.
  2. Add EmailValidator::__construct(..., ?bool $makeHostAbsolute = null) with same BC logic.
  3. Add @Email::?bool $makeHostAbsolute = null to be able to override validator's default value when needed.
  4. if ($makeHostAbsolute && '.' !== mb_substr($email, -1)) { $email .= '.'; }

Ready to work on the PR.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions