Skip to content
This repository has been 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 opened this issue Sep 28, 2016 · 3 comments
Labels

Comments

@thexpand
Copy link

thexpand commented Sep 28, 2016

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.

@adamlundrigan
Copy link
Contributor

adamlundrigan commented Oct 1, 2016

Sorry, I'm not 100% clear on the problem: is it that тест@example.com is being accepted by the validator when you think it shouldn't? Or is the problem in sending an email to that validated address?("Afterwards, sending an e-mail is impossible...")

If it's the former, UTF-8 characters above U+007F are technically allowed in the email address local part (RFC 6531) though I don't know anything about specific implementations and what they do or don't accept.

@thexpand
Copy link
Author

thexpand commented Oct 2, 2016

I thought that the validator should not accept UTF-8 characters in the local part at all.
Maybe I was wrong.

However, there is a problem afterwards when sending the e-mail.
The headers seems to be invalid.
Because of the invalid headers I thought that the validator is not working right.

Any ideas?

@weierophinney
Copy link
Member

This repository has been closed and moved to laminas/laminas-validator; a new issue has been opened at laminas/laminas-validator#22.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants