]> git.deb.at Git - deb/packages.git/blobdiff - cgi-bin/dispatcher.pl
remove $SEARCH_CGI since it is always identical with $SEARCH_URL
[deb/packages.git] / cgi-bin / dispatcher.pl
index ea7c3e2fd6a988582be92e13b5b18fdd590de7b0..3dca95cfdbaa5d4843cfd5a6fe2333671594de45 100755 (executable)
@@ -16,11 +16,10 @@ use POSIX;
 use URI::Escape;
 use HTML::Entities;
 use DB_File;
-use Benchmark;
+use Benchmark ':hireswallclock';
 
 use Deb::Versions;
-use Packages::Config qw( $DBDIR $ROOT $SEARCH_CGI $SEARCH_PAGE
-                        @SUITES @SECTIONS @ARCHIVES @ARCHITECTURES );
+use Packages::Config qw( $DBDIR $ROOT @SUITES @SECTIONS @ARCHIVES @ARCHITECTURES );
 use Packages::CGI;
 use Packages::DB;
 use Packages::Search qw( :all );
@@ -59,19 +58,22 @@ $Packages::CGI::debug = $debug;
 my $what_to_do = 'show';
 my $source = 0;
 if (my $path = $input->path_info() || $input->param('PATH_INFO')) {
-    my @components = grep { $_ } map { lc $_ } split /\/+/, $path;
+    my @components = grep { $_ } map { lc $_ } split /\//, $path;
 
-    debug( "components[0]=$components[0]", 2 );
-    if ($components[0] eq 'search') {
-       shift @components;
-       $what_to_do = 'search';
-    }
-    if ($components[0] eq 'source') {
+    debug( "components[0]=$components[0]", 2 ) if @components>0;
+    if (@components > 0 and $components[0] eq 'source') {
        shift @components;
        $input->param( 'source', 1 );
     }
-    if (@components == 0) {
-       # we just hope we get the information through our parameters...
+    if (@components > 0 and $components[0] eq 'search') {
+       shift @components;
+       $what_to_do = 'search';
+       # Done
+       fatal_error( "search doesn't take any more path elements" )
+           if @components > 0;
+    } elsif (@components == 0) {
+       fatal_error( "We're supposed to display the homepage here, instead of
+           getting dispatch.pl" );
     } elsif (@components == 1) {
        $what_to_do = 'search';
     } else {
@@ -152,7 +154,7 @@ my %params_def = ( keywords => { default => undef,
                                    match => '^([\w-]+)$',
                                    array => ',', var => \@archives,
                                    replace => { all => \@ARCHIVES,
-                                            default => [qw(us security non-US)]} },
+                                                default => [qw(us security non-US)]} },
                   exact => { default => 0, match => '^(\w+)$',  },
                   source => { default => 0, match => '^(\d+)$',  },
                   searchon => { default => 'names', match => '^(\w+)$', },
@@ -163,7 +165,7 @@ my %params_def = ( keywords => { default => undef,
                   subsection => { default => 'default', match => '^([\w-]+)$',
                                   array => ',', var => \@subsections,
                                   replace => { default => [] } },
-                  arch => { default => 'any', match => '^(\w+)$',
+                  arch => { default => 'any', match => '^([\w-]+)$',
                             array => ',', var => \@archs, replace =>
                             { any => \@ARCHITECTURES } },
                   );