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

Email Validation Test Fails for Invalid Domain #59

Open
carlos-alex opened this issue Sep 21, 2024 · 3 comments
Open

Email Validation Test Fails for Invalid Domain #59

carlos-alex opened this issue Sep 21, 2024 · 3 comments
Assignees
Labels
bug Something isn't working

Comments

@carlos-alex
Copy link

In the Email Validation Tests using Utilities, the test case with TestId: 86 (email: [email protected]) incorrectly returns true instead of false. The domain contains an invalid character (0 in .c0m), which should fail the validation but passes as valid.

Expected:
The test should return false for an invalid domain like c0m.

Actual:
The test returns true, indicating the email is valid when it should be invalid.

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

for (var testCase in testCases) {
test('TestId: ${testCase['testId']} - Testing email: ${testCase['email']}', () {
bool result = isEmailValid(testCase['email'] as String);
expect(result, testCase['expectedResult']);
});
}

final testCases = [ ...
{
'testId': 86,
'email': '[email protected]',
'expectedResult': false,
},
... ]

bool isEmailValid(String email) {
return EmailValidator.validate(email);
}

email_validator: ^3.0.0

Email Validation Tests using Utilities TestId: 86 - Testing email: [email protected] [E]
Expected:
Actual:

@fredeil fredeil self-assigned this Oct 9, 2024
@fredeil fredeil added the bug Something isn't working label Oct 9, 2024
@fredeil
Copy link
Owner

fredeil commented Oct 9, 2024

Numbers in TLDs are valid (just look at the punycode TLDS). This library doesn't check if a TLD is an existing TLD (c0m for example), that would be up to you. There are libraries and resources online on how to verify TLDs, and there has been suggestions to add it to this library, but I've decided to not clutter this library with doesn't have anything with the email syntax to do, see these issues:

For reference, read https://stackoverflow.com/questions/9071279/number-in-the-top-level-domain.

Closing this issue for now.

@fredeil fredeil closed this as completed Oct 9, 2024
@carlos-alex
Copy link
Author

I'm not entirely convinced, but ... okay!

++++++++++++++++++++++

In RFC 1035, which deals with the Domain Name System (DNS), there is no explicit mention that numbers are disallowed in domain names. However, it provides rules for label formats and restrictions on how domain names should be structured. It specifies that domain names are built from labels, which must be between 1 and 63 characters long, and each label can contain letters, digits, and hyphens (-). Importantly, labels cannot begin or end with a hyphen, and there are no restrictions against using numbers within domain names, including top-level domains (TLDs).

This means that numbers are allowed in domain names, but numeric TLDs like .c0m are invalid because .com is the only recognized TLD in that context, and the ICANN rules prohibit creating new TLDs that deviate from their predefined list (which you can check on IANA's website).

The relevant sections of RFC 1035 outline the technical structure of DNS, but specific prohibitions about invalid TLDs (like .c0m) come from ICANN's domain registration rules​(
RFC Annotations
)​(
Free Software Foundation
).

+++++++++++++++++
The domain .c1m would also be invalid, just like .c0m. This is because .c1m is not an existing Top-Level Domain (TLD) recognized by the IANA (Internet Assigned Numbers Authority) or ICANN (Internet Corporation for Assigned Names and Numbers).

The list of valid TLDs is strictly controlled and does not include any that are a mix of letters and numbers like .c1m or .c0m. TLDs are generally either generic (e.g., .com, .org, .net) or country-code TLDs (e.g., .us, .uk, .br), and they follow specific naming conventions, usually without the inclusion of numbers in this position.
++++++++++++++++

@fredeil fredeil reopened this Oct 16, 2024
@fredeil
Copy link
Owner

fredeil commented Oct 16, 2024

Ill reopen for discussions. Thanks for contributing @carlos-alex 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants