also support regexp in domain_suffix

This commit is contained in:
Oliver Gorwits
2019-09-03 13:35:26 +01:00
parent 0a2b5c8fa2
commit 975e4c6afc
2 changed files with 4 additions and 3 deletions

View File

@@ -141,7 +141,8 @@ config->{'domain_suffix'} = [setting('domain_suffix')]
if ref [] ne ref setting('domain_suffix');
if (scalar @{ setting('domain_suffix') }) {
my @suffixes = map { quotemeta } @{ setting('domain_suffix') };
my @suffixes = map { (ref qr// eq ref $_) ? $_ : quotemeta }
@{ setting('domain_suffix') };
my $buildref = '(?:'. (join '|', @suffixes) .')$';
config->{'domain_suffix'} = qr/$buildref/;
}

View File

@@ -151,11 +151,11 @@ sub search_by_dns {
if ref {} ne ref $cond or !exists $cond->{dns};
(my $suffix = (delete $cond->{suffix} || ''))
=~ s|^\Q(?^\E|***:(?|;
=~ s|\Q(?^\Eu?|(?|g;
$cond->{dns} = [ -and =>
{ '-ilike' => delete $cond->{dns} },
{ '~*' => "$suffix" },
{ '~*' => "***:$suffix" },
];
return $rs