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

Incorrect default email length 255. #658

Closed
jenstroeger opened this issue Nov 15, 2022 · 4 comments
Closed

Incorrect default email length 255. #658

jenstroeger opened this issue Nov 15, 2022 · 4 comments

Comments

@jenstroeger
Copy link

The default length of a string to store an email is currently 255:

def __init__(self, length=255, *args, **kwargs):

However, according to the RFC and also this discussion the maximum length of an email address is 254:

In addition to restrictions on syntax, there is a length limit on
email addresses. That limit is a maximum of 64 characters (octets)
in the "local part" (before the "@") and a maximum of 255 characters
(octets) in the domain part (after the "@") for a total length of 320
characters. However, there is a restriction in RFC 2821 on the length of an
address in MAIL and RCPT commands of 254 characters. Since addresses
that do not fit in those fields are not normally useful, the upper
limit on address lengths should normally be considered to be 254.

This is probably not a big issue but should be considered for accuracy’s sake.

(See also related old PR #230.)

@kurtmckee
Copy link
Collaborator

Because the default is close to but not less than the maximum; and because this is a default that can be changed as needed; and because this default has been deployed for several years; I don't currently see a reason to decrease the default to 254.

@jenstroeger
Copy link
Author

Hmm… ok. Keeping in mind, though, that the current default enables people to store invalid email addresses, i.e. one character too long.

@kurtmckee
Copy link
Collaborator

It's also possible that people might store things that are convenient to store as email addresses but aren't guaranteed to be. For example, a service may want to store author email addresses listed in git commits, which may not be valid email addresses.

Developers will simply need to control their inputs and requirements. Enforcement shouldn't happen from the database layer.

@jenstroeger
Copy link
Author

jenstroeger commented Nov 15, 2022

Yeah the problem of “syntactically correct” email address vs. “valid” actual email address.

Developers will simply need to control their inputs and requirements. Enforcement shouldn't happen from the database layer.

I kind-of agree, though my OCD-driven nit-picking engineering attitude squirms a bit 😉 I’m using EmailType(length=254) and thought I’d prettify that by fixing the default length. Ah so.

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

No branches or pull requests

2 participants