From: Michal Vaner Date: Mon, 8 Dec 2008 12:46:01 +0000 (+0100) Subject: Do not fail when jumping from help X-Git-Url: http://mj.ucw.cz/gitweb/?a=commitdiff_plain;h=39c124425459c4a291a4e4bccdf4c46217be006a;p=pciids.git Do not fail when jumping from help --- diff --git a/PciIds/Html/Handler.pm b/PciIds/Html/Handler.pm index 100726c..f9ca889 100644 --- a/PciIds/Html/Handler.pm +++ b/PciIds/Html/Handler.pm @@ -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 ); diff --git a/PciIds/Html/Jump.pm b/PciIds/Html/Jump.pm index 973a221..53cab90 100644 --- a/PciIds/Html/Jump.pm +++ b/PciIds/Html/Jump.pm @@ -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/^\*//;