Skip to content
This repository was archived by the owner on Jan 31, 2020. It is now read-only.

Cannot correctly validate cyrillic (or any other UTF-8) characters in local part #119

Open
@thexpand

Description

@thexpand

Here is the usage of the validator in the form:

[
    "name" => "email",
    "required" => false,
    "validators" => [
        [
            "name" => "EmailAddress"
        ]
    ]
]

The problem occurs when the user enters an email with UTF-8 characters in the local part.
Here is an example: тест@example.com

While debugging, Zend\Validator\EmailAddress::validateLocalPart() returns (boolean) true, thus causing the input to be valid (but it isn't).

Afterwards, sending an e-mail is impossible, because тест@example.com gets into the e-mail headers and they become invalid.

I have investigated the problem and it turns out that $this->idnToAscii($this->localPart) in the Zend\Validator\EmailAddress::validateLocalPart() method is causing the problem. It converts all UTF-8 characters to ASCII and makes the preg_match. It returns true and voila - wrong validation.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions