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

Domains should not be able to end with a period #73

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/AddressExtractor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public partial class AddressExtractor
/// Email Regex pattern with simple checks and no backtrack
/// </summary>
[GeneratedRegex(
"""[\\"']*[a-z0-9\.\-\*!#$%&+=?^_`{|}~\\]+@([a-z0-9\-]+[a-z0-9\-]*\.)+[a-z0-9]{2,}\b[\\"']*""",
"""[\\"']*[a-z0-9\.\-\*!#$%&+=?^_`{|}~\\]+@([a-z0-9\-]+[a-z0-9\-]*\.)+[a-z0-9]{2,}\.?[\\"']*""",
RegexOptions.ExplicitCapture // Require naming captures; implies '(?:)' on groups. We don't make use of the groups
| RegexOptions.IgnoreCase // Match upper and lower casing
| RegexOptions.Compiled // Compile the nodes
Expand Down
4 changes: 4 additions & 0 deletions src/Objects/Filters/DomainFilter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ public override Result ValidateEmailAddress(ref EmailAddress address)
{
var domain = address.Domain;

// Handle domain ending in period
if (domain[domain.Length - 1].Equals('.'))
return Result.DENY;

// Handle cases such as: foo@bar.1com, foo@bar.12com
if (char.IsNumber(domain[domain.LastIndexOf('.')+1]))
return Result.DENY;
Expand Down