From: Daniel Berteaud <daniel@firewall-services.com>
To: pmg-devel@lists.proxmox.com
Subject: [pmg-devel] [PATCH v2 pmg-api 1/1] [pmg-api] fix #3098 sort domains by length first
Date: Wed, 28 Oct 2020 11:20:15 +0100 [thread overview]
Message-ID: <20201028102015.628005-2-daniel@firewall-services.com> (raw)
In-Reply-To: <20201028102015.628005-1-daniel@firewall-services.com>
So if we have a sub domain and its parent in the list, the correct one will be returned
Signed-off-by: Daniel Berteaud <daniel@firewall-services.com>
---
src/PMG/DKIMSign.pm | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/src/PMG/DKIMSign.pm b/src/PMG/DKIMSign.pm
index 7cb06a6..08197f8 100644
--- a/src/PMG/DKIMSign.pm
+++ b/src/PMG/DKIMSign.pm
@@ -69,7 +69,9 @@ sub signing_domain {
my $dkimdomains = PVE::INotify::read_file('dkimdomains');
$dkimdomains = PVE::INotify::read_file('domains') if !scalar(%$dkimdomains);
- foreach my $domain (sort keys %$dkimdomains) {
+ # Sort domains by length first, so if we have both a sub domain and its parent
+ # the correct one will be returned
+ foreach my $domain (sort { length($b) <=> length($a) || $a cmp $b} keys %$dkimdomains) {
if ( $input_domain =~ /\Q$domain\E$/i ) {
$self->domain($domain);
return 1;
--
2.26.2
next prev parent reply other threads:[~2020-10-28 10:20 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-10-28 10:20 [pmg-devel] [PATCH v2 pmg-api 0/1] Select the correct domain for the DKIM Daniel Berteaud
2020-10-28 10:20 ` Daniel Berteaud [this message]
2020-10-29 10:05 ` [pmg-devel] [PATCH v2 pmg-api 1/1] [pmg-api] fix #3098 sort domains by length first Stoiko Ivanov
2020-11-18 7:11 ` [pmg-devel] applied: " Thomas Lamprecht
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20201028102015.628005-2-daniel@firewall-services.com \
--to=daniel@firewall-services.com \
--cc=pmg-devel@lists.proxmox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.