From 2bb4dad06e5f457847db91ff49b516fbd407184b Mon Sep 17 00:00:00 2001 From: Don Armstrong Date: Wed, 24 Sep 2008 08:49:51 -0700 Subject: [PATCH] Return 404 when a bug number that does not exist is used (closes: #499997) --- Debbugs/Common.pm | 5 ++++- cgi/bugreport.cgi | 8 ++++++++ debian/changelog | 2 ++ templates/en_US/cgi/no_such_bug.tmpl | 2 +- 4 files changed, 15 insertions(+), 2 deletions(-) diff --git a/Debbugs/Common.pm b/Debbugs/Common.pm index a444a46..87b3559 100644 --- a/Debbugs/Common.pm +++ b/Debbugs/Common.pm @@ -162,6 +162,8 @@ sub get_hashname { Returns the path to the logfile corresponding to the bug. +Returns undef if the bug does not exist. + =cut sub buglog { @@ -169,7 +171,8 @@ sub buglog { my $location = getbuglocation($bugnum, 'log'); return getbugcomponent($bugnum, 'log', $location) if ($location); $location = getbuglocation($bugnum, 'log.gz'); - return getbugcomponent($bugnum, 'log.gz', $location); + return getbugcomponent($bugnum, 'log.gz', $location) if ($location); + return undef; } diff --git a/cgi/bugreport.cgi b/cgi/bugreport.cgi index b325863..d01a286 100755 --- a/cgi/bugreport.cgi +++ b/cgi/bugreport.cgi @@ -71,6 +71,14 @@ my $archive = $param{'archive'} eq 'yes'; my $repeatmerged = $param{'repeatmerged'} eq 'yes'; my $buglog = buglog($ref); +if (not defined $buglog) { + print $q->header(-status => "404 No such bug", + -type => "text/html", + -charset => 'utf-8', + ); + exit 0; +} + my @stat = stat $buglog; my $mtime = ''; if (@stat) { diff --git a/debian/changelog b/debian/changelog index f4ddd6b..949ef46 100644 --- a/debian/changelog +++ b/debian/changelog @@ -222,6 +222,8 @@ debbugs (2.4.2) UNRELEASED; urgency=low * Add correspondent option to track bug correpondents (closes: #485804) * Allow clicking anywhere outside the extra status box to close the extra status box (closes: #499990) Thanks to James Vega for the patch. + * Return 404 when a bug number that does not exist is used + (closes: #499997) -- Colin Watson Fri, 20 Jun 2003 18:57:25 +0100 diff --git a/templates/en_US/cgi/no_such_bug.tmpl b/templates/en_US/cgi/no_such_bug.tmpl index 107f9f2..5434b53 100644 --- a/templates/en_US/cgi/no_such_bug.tmpl +++ b/templates/en_US/cgi/no_such_bug.tmpl @@ -5,5 +5,5 @@

{$config{project}} {$config{bug}} report logs - #{$bug_num}

There is no record of {$config{bug}} #{$bug_num}. Try the search page instead.

-{include('html/tail')} +{#include('html/html_tail')} -- 2.39.2