validatorjs / validator.js

String validation
MIT License
23.12k stars 2.31k forks source link

What is the right domain length? #655

Open michaeljota opened 7 years ago

michaeljota commented 7 years ago

According to this guy the domain length should be 254 chars at most, but the isEmail function it's checking for a 256 chars length, that is was once considered ok, but it seems like it was an errata

Which one is correct?

chriso commented 7 years ago

It sounds like it should be 254.

korvent commented 6 years ago

You misunderstood. It is said:

What is the length of an email address? The correct answer seems to be in the errata with ID 1690 from RFC 3696: "[...] the upper limit on address lengths should normally be considered to be 254."

This does not concern the length of the domain part but the entire email address.

Furthermore there is an error in this errata: RFC 2821 says (https://tools.ietf.org/html/rfc2821#page-17):

RCPT TO:<forward-path> [ SP <rcpt-parameters> ] <CRLF> The first or only argument to this command includes a forward-path (normally a mailbox and domain, always surrounded by "<" and ">" brackets) identifying one recipient.

and (https://tools.ietf.org/html/rfc2821#page-55):

The maximum total length of a reverse-path or forward-path is 256 characters (including the punctuation and element separators).

so the total length of forward-path (the email address) is well 256 and not 254.

Concerning the domain length: RFC 3696 says (https://tools.ietf.org/html/rfc3696#page-5):

A complete, fully-qualified, domain name must not exceed 255 octets.

RFC 2821 says (https://tools.ietf.org/html/rfc2821#page-55):

The maximum total length of a domain name or number is 255 characters.

In summary:

References https://tools.ietf.org/html/rfc3696#page-5 https://tools.ietf.org/html/rfc2821#page-17 https://tools.ietf.org/html/rfc2821#page-55

ezkemboi commented 5 years ago

I will try to do more investigation on how to solve this bug.

sakhmedbayev commented 1 year ago

It seems it supports only 64 characters long domain parts, so it supports the same length for both local and domain parts???

WikiRik commented 1 year ago

The 'domain part' is allowed to be longer than 64 characters, see the following part of the source code; https://github.com/validatorjs/validator.js/blob/531dc7f1f75613bec75c6d888b46480455e78dc7/src/lib/isEmail.js#L135-L140