Regex TLD Optimisation Help

Dec 27, 2020
108
16
23
44
Hi All,

After discovering how to apply Custom Rules, its got me down this RegEx rabbit hole.

Is anyone able to help with the following that I have 'hacked' together - it is working, but not optimal IMO for both header and URI searches.

Code:
(\.(fit|link)+?)(?:$|\/|\:)
https://regex101.com/r/dezYX0/3

What I would like to ask is:
  1. How can I ignore everything after the end of TLD (refer to link)
  2. Is the code the shortest/simplest it can be
Thanks for the read ;)
 
I use below who object regex to filter emails address from some suspicious tld.

(\W|^)[\w.+\-\=]{0,50}@[\w.+\-\=]{0,50}\.top(\W|$) or (\W|^)[\w.+\-]{0,50}@[\w.+\-]{0,50}\.top(\W|$)
 
Thanks @hata_ph, I beleive it is very similar, and I had cut out the parts before the @. It works for an email address, however in the event that it was placed in the extended url portion, that RegEx could be a problem:

1628570544273.png

I know the probability of a .TLD occuring in a link is low, however I just want to make sure the probability is zero as I am sure somewhere down the line someone will complain to me why a particular email was 'quarantined' becuase my rule just pushed it over the threshold. "sigh"...
 
Are you using PMG mail filter object rules or custom spamassassin rules?
 
THe problem with that is that it searches for a '.' then 'tld'. This is a problem as the following would be hit also (along with subdomains):

1628590716702.png

Thats why I had searchs for the proceeding colon, forward slash or end of line.

Yes I am over-thinking it - however I am sure there is a way to give it better protection.
 

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!