Regex matching PMG 7.3

Feb 24, 2023
5
0
1
Hello,

since nobody in the German sub seemed to know the answer to this I'll try again here. In my installation I have several regexes for filtering mails from sketchy or untrustworthy toplevel domains like .lol.
Since the update 7.3-7 none of the regexes seems to match any domain. Here is my regex for the mentioned example .lol

Code:
.*([0-9a-z|-]+\.)[0-9a-z|-]+\.(lol)+

Mails from the domain lockermaster.lol were delivered to the users despite this rule. (screenshot)
 

Attachments

  • Screenshot 2023-07-28 163811a.png
    Screenshot 2023-07-28 163811a.png
    23.2 KB · Views: 17
The regex you posted demands at least one subdomain. So “lockermaster.lol” does not match this regex, but “a.lockermaster.lol” does. Also note that .* at the beginning can make this regex very inefficient.

Small break down of the regex:
  • .*: match any character as often as possible. This leads to back-tracking making the regex inefficient.
  • ([0-9a-z|-]+\.): capturing group one, match any of the characters between “0” and “9”, “a” and “z”, as well as “|” and “-” one or more times and then a period. This requires a subdomain.
  • [0-9a-z|-]+\.: match the same stuff again one or more times followed by a period. This would match the main domain.
  • (lol)+ capture group two, match the string “lol” one or more times. This would then match the TLD “lol”, but also “lollol” and “lollollol” and so on.
If all you want to do is match every “.lol” TLD, you could try \.lol$. This would demand that at the end of the string “.lol” occurs.

You can use websites such as Regex 101 [1] to gain a better understand of how regexes work.

[1]: https://regex101.com/
 
Hi sterzy,

the
Code:
.*
at the beginning was suggested by another user here some time ago.

I personaly prefer regexr.com for Testing but I'm getting the feeling that pmg does not evaluate regexes the same way as other applications.

Your suggestion
Code:
\.lol$
does not match "lockermaster.lol" according to pmg.
 

Attachments

  • regex_lol.png
    regex_lol.png
    22.2 KB · Views: 9
Ah, I see this particular regex is automatically anchored. Then yeah, you'll need to use this one instead .*\.lol, which will be anchored and become this regex ^.*\.lol$. So it will match the beginning of a line (“^”), then any character zero or more times (“.*”), then the string “.lol” and then the end of line (“$”). This should still match anything ending in “.lol” and be more efficient than your original regex for cases such as “a.lockermaster.lol.lol” (12 vs. 49 steps).
 
Last edited:

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!