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

Wrong regex for extracting From domain #64

Closed
marc-vanderwal opened this issue Apr 5, 2023 · 1 comment
Closed

Wrong regex for extracting From domain #64

marc-vanderwal opened this issue Apr 5, 2023 · 1 comment

Comments

@marc-vanderwal
Copy link

The following line uses a regular expression to attempt extracting the domain name of the From header:

if (preg_match("/[@]([a-zA-Z0-9]+([.][a-zA-Z0-9]+)?\.[a-zA-Z]{2,4})/", $headers->from, $m)) {

However this regular expression is incorrect, for several reasons:

  • domain name labels (including top-level domains) may also contain hyphens;
  • TLDs exist that are more than 4 characters long, e.g. .paris (and there are much longer TLDs on ICANN’s list).

On a closed test network where I was using domain names ending in .example, this causes an e-mail whose sender domain is sender.example to be labeled STATUS_THIRD by this plugin despite SPF, DKIM and DMARC passing, all at sender.example. Adjusting the {2,4} to {2,7} as a test yielded STATUS_PASS instead.

@pimlie
Copy link
Owner

pimlie commented Jan 15, 2025

Thanks for the report, seems I fixed this last year already but forgot to resolve this issue. See #71, just reverted back to the most basic domain extraction I know ;)

@pimlie pimlie closed this as completed Jan 15, 2025
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