From 975e4c6afc4488007d0ff5d40d945e91f6abe4fb Mon Sep 17 00:00:00 2001 From: Oliver Gorwits Date: Tue, 3 Sep 2019 13:35:26 +0100 Subject: [PATCH] also support regexp in domain_suffix --- lib/App/Netdisco/Configuration.pm | 3 ++- lib/App/Netdisco/DB/ResultSet/NodeIp.pm | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/App/Netdisco/Configuration.pm b/lib/App/Netdisco/Configuration.pm index f2f69673..064e43c4 100644 --- a/lib/App/Netdisco/Configuration.pm +++ b/lib/App/Netdisco/Configuration.pm @@ -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/; } diff --git a/lib/App/Netdisco/DB/ResultSet/NodeIp.pm b/lib/App/Netdisco/DB/ResultSet/NodeIp.pm index d56660fc..52c8d232 100644 --- a/lib/App/Netdisco/DB/ResultSet/NodeIp.pm +++ b/lib/App/Netdisco/DB/ResultSet/NodeIp.pm @@ -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