On 2021-11-04 11:20, Viktor Dukhovni wrote:
On Thu, Nov 04, 2021 at 10:52:03AM -0700, [email protected] wrote:In main.cf I have: sender_canonical_classes = envelope_sender sender_canonical_maps = pcre:/etc/postfix/generic-pcre In /etc/postfix/generic-pcre I have: /^(.*)@(\w+).([.\w]+)/ ${1}+${2}@other.domainThis rule is sloppy, fails to handle recursion, and does not handle valid labels with hyphens. In a regular expression, when you mean to match a "." write either "\." or "[.]", but never just ".". Regular expressions are fragile, don't wing it. Instead use: # Presumably this is internal only, and never butchers external # envelope sender addresses. Perhaps mention why it is OK to lop # off the parent domain suffix of the original sender domain... ## This only matches valid multi-label DNS names. What should happen# with invalid forms (e.g., <[email protected]>, <user@-foo+bar.net>)? # if !/@other\.domain$/ /^(.*)@([a-z0-9](-*[a-z0-9]+)*)\.[a-z0-9]/ ${1}+${2}@other.domain endif
Thank you for the reply. Let me take a looks at this. For sure, my regular expressions knowledge is extremely limited at best. Appreciate the feedback.
As documented, canonical rewriting is recursive.
