Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
weierophinney opened this issue Dec 31, 2019 · 2 comments
Assignees
Labels
Question Further information is requested

Comments

@weierophinney
Copy link
Member

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.


Originally posted by @thexpand at zendframework/zend-validator#119

@weierophinney weierophinney added the Question Further information is requested label Dec 31, 2019
@weierophinney
Copy link
Member Author

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.


Originally posted by @adamlundrigan at zendframework/zend-validator#119 (comment)

@weierophinney
Copy link
Member Author

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?


Originally posted by @thexpand at zendframework/zend-validator#119 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants