From 8ec8da0491ad89604700b3e29a227966f6d84ba1 Mon Sep 17 00:00:00 2001 From: Perl Tidy Date: Wed, 5 Dec 2018 15:38:52 -0500 Subject: no bug - reformat all the code using the new perltidy rules --- page.cgi | 79 +++++++++++++++++++++++++++++++++------------------------------- 1 file changed, 41 insertions(+), 38 deletions(-) (limited to 'page.cgi') diff --git a/page.cgi b/page.cgi index 3784b92ed..82d8ce064 100755 --- a/page.cgi +++ b/page.cgi @@ -30,16 +30,17 @@ use Bugzilla::Search::Quicksearch; # For quicksearch.html. sub quicksearch_field_names { - my $fields = Bugzilla::Search::Quicksearch->FIELD_MAP; - my %fields_reverse; - # Put longer names before shorter names. - my @nicknames = sort { length($b) <=> length($a) } (keys %$fields); - foreach my $nickname (@nicknames) { - my $db_field = $fields->{$nickname}; - $fields_reverse{$db_field} ||= []; - push(@{ $fields_reverse{$db_field} }, $nickname); - } - return \%fields_reverse; + my $fields = Bugzilla::Search::Quicksearch->FIELD_MAP; + my %fields_reverse; + + # Put longer names before shorter names. + my @nicknames = sort { length($b) <=> length($a) } (keys %$fields); + foreach my $nickname (@nicknames) { + my $db_field = $fields->{$nickname}; + $fields_reverse{$db_field} ||= []; + push(@{$fields_reverse{$db_field}}, $nickname); + } + return \%fields_reverse; } ############### @@ -48,38 +49,40 @@ sub quicksearch_field_names { Bugzilla->login(); -my $cgi = Bugzilla->cgi; +my $cgi = Bugzilla->cgi; my $template = Bugzilla->template; my $id = $cgi->param('id'); if ($id) { - # Be careful not to allow directory traversal. - if ($id =~ /\.\./) { - # two dots in a row is bad - ThrowCodeError("bad_page_cgi_id", { "page_id" => $id }); - } - # Split into name and ctype. - $id =~ /^([\w\-\/\.]+)\.(\w+)$/; - if (!$2) { - # if this regexp fails to match completely, something bad came in - ThrowCodeError("bad_page_cgi_id", { "page_id" => $id }); - } - - my %vars = ( - quicksearch_field_names => \&quicksearch_field_names, - ); - Bugzilla::Hook::process('page_before_template', - { page_id => $id, vars => \%vars }); - - my $format = $template->get_format("pages/$1", undef, $2); - - $cgi->param('id', $id); - - print $cgi->header($format->{'ctype'}); - - $template->process("$format->{'template'}", \%vars) - || ThrowTemplateError($template->error()); + + # Be careful not to allow directory traversal. + if ($id =~ /\.\./) { + + # two dots in a row is bad + ThrowCodeError("bad_page_cgi_id", {"page_id" => $id}); + } + + # Split into name and ctype. + $id =~ /^([\w\-\/\.]+)\.(\w+)$/; + if (!$2) { + + # if this regexp fails to match completely, something bad came in + ThrowCodeError("bad_page_cgi_id", {"page_id" => $id}); + } + + my %vars = (quicksearch_field_names => \&quicksearch_field_names,); + Bugzilla::Hook::process('page_before_template', + {page_id => $id, vars => \%vars}); + + my $format = $template->get_format("pages/$1", undef, $2); + + $cgi->param('id', $id); + + print $cgi->header($format->{'ctype'}); + + $template->process("$format->{'template'}", \%vars) + || ThrowTemplateError($template->error()); } else { - ThrowUserError("no_page_specified"); + ThrowUserError("no_page_specified"); } -- cgit v1.2.3-24-g4f1b