]> mj.ucw.cz Git - pciids.git/commitdiff
Do not fail when jumping from help
authorMichal Vaner <vorner@ucw.cz>
Mon, 8 Dec 2008 12:46:01 +0000 (13:46 +0100)
committerMichal Vaner <vorner@ucw.cz>
Mon, 8 Dec 2008 12:46:01 +0000 (13:46 +0100)
PciIds/Html/Handler.pm
PciIds/Html/Jump.pm

index 100726c9befbcc1e366564ede8acd03976f71f27..f9ca889e5dd2830b303ac5e642ab7f2a3fd89911 100644 (file)
@@ -80,7 +80,7 @@ my %handlers = (
 sub handler( $$ ) {
        my( $req, $hasSSL ) = @_;
        my $args = parseArgs( $req->args() );
-       return HTTPRedirect( $req, protoName( $hasSSL ).'://'.$req->hostname().'/index.html' ) if( $req->uri() eq '/' && ( !defined $args->{'action'} || $args->{'action'} ne 'help' ) );
+       return HTTPRedirect( $req, protoName( $hasSSL ).'://'.$req->hostname().'/index.html' ) if( $req->uri() eq '/' && ( !defined $args->{'action'} || ( $args->{'action'} ne 'help' && $args->{'action'} ne 'jump' ) ) );
        return DECLINED if( $req->uri() =~ /^\/((static)\/|robots.txt|index.html)/ );
        my $action = $args->{'action'};
        $action = '' unless( defined $action );
index 973a22178203eab2270ff8aaf41eea7ac6435cf8..53cab903ebc4fb51bead434a884045c1bc7801d2 100644 (file)
@@ -54,13 +54,15 @@ sub tryDirect( $$$$$ ) {
        my $address = PciIds::Address::new( $req->uri() );
        $search =~ s/:/\//g;
        $search =~ s/ //g;
-       my( $top ) = $address->get() =~ /^([^\/]+)/;
-       $search =~ s/^\//$top\//;
-       #Is it absolute address?
-       my $saddr = PciIds::Address::new( $search );
-       return redirect( $req, $args, $saddr->get(), $hasSSL ) if( defined $saddr && itemExists( $tables, $saddr->get() ) );
+       if( defined $address ) {
+               my( $top ) = $address->get() =~ /^([^\/]+)/;
+               $search =~ s/^\//$top\//;
+               #Is it absolute address?
+               my $saddr = PciIds::Address::new( $search );
+               return redirect( $req, $args, $saddr->get(), $hasSSL ) if( defined $saddr && itemExists( $tables, $saddr->get() ) );
+       }
        while( defined $address ) {
-               $saddr = PciIds::Address::new( $address->get()."/$search" );
+               my $saddr = PciIds::Address::new( $address->get()."/$search" );
                return redirect( $req, $args, $saddr->get(), $hasSSL ) if( defined $saddr && itemExists( $tables, $saddr->get() ) );
                $address = $address->parent();
        }
@@ -75,6 +77,7 @@ sub jump( $$$$ ) {
        my $direct = tryDirect( $req, $args, $tables, $search, $auth->{'ssl'} );
        return $direct if defined $direct;
        my $address = PciIds::Address::new( $req->uri() );
+       $address = PciIds::Address::new( 'PC' ) unless defined $address;
        unless( $idOnly || length $search < 3 ) {#Try extended search
                my( $prefix ) = $address->get() =~ /^([^\/]+)/;
                $prefix = undef if $search =~ s/^\*//;