From 3662899ede24682e62a818028bf96a5cb553ff68 Mon Sep 17 00:00:00 2001 From: Oliver Gorwits Date: Sun, 24 May 2020 19:41:21 +0100 Subject: [PATCH] #721 search will trim whitespace and handle more MAC formats --- Changes | 6 ++++++ lib/App/Netdisco/Web.pm | 3 +++ lib/App/Netdisco/Web/Search.pm | 2 +- 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/Changes b/Changes index b67a2f85..75179272 100644 --- a/Changes +++ b/Changes @@ -1,3 +1,9 @@ +2.045006 - 2020-05-24 + + [ENHANCEMENTS] + + * #721 search will trim whitespace and handle more MAC formats + 2.045005 - 2020-05-18 [BUG FIXES] diff --git a/lib/App/Netdisco/Web.pm b/lib/App/Netdisco/Web.pm index cb0b0c01..a91b37a8 100644 --- a/lib/App/Netdisco/Web.pm +++ b/lib/App/Netdisco/Web.pm @@ -145,6 +145,9 @@ hook 'before' => sub { $key =~ s|.*/(\w+)/(\w+)$|${1}_${2}|; var(sidebar_key => $key); + # trim whitespace + params->{'q'} =~ s/^\s+|\s+$//g if param('q'); + # copy sidebar defaults into vars so we can mess about with it foreach my $sidebar (keys %{setting('sidebar_defaults')}) { vars->{'sidebar_defaults'}->{$sidebar} = { map { diff --git a/lib/App/Netdisco/Web/Search.pm b/lib/App/Netdisco/Web/Search.pm index 3c1d9005..2f59e2c6 100644 --- a/lib/App/Netdisco/Web/Search.pm +++ b/lib/App/Netdisco/Web/Search.pm @@ -32,7 +32,7 @@ get '/search' => require_login sub { } # pick most likely tab for initial results - if ($q =~ m/^\d+$/) { + if ($q =~ m/^[0-9]+$/ and $q < 4096) { params->{'tab'} = 'vlan'; } else {