Commit 5fed7ece authored by travis%sedsystems.ca's avatar travis%sedsystems.ca

Bug 153461: describe components shouldn't give an error for a bad product

Patch: LpSolit@netscape.net r=mkanat a=justdave
parent 26276ec4
...@@ -21,27 +21,25 @@ ...@@ -21,27 +21,25 @@
# Contributor(s): Terry Weissman <terry@mozilla.org> # Contributor(s): Terry Weissman <terry@mozilla.org>
# Bradley Baetz <bbaetz@student.usyd.edu.au> # Bradley Baetz <bbaetz@student.usyd.edu.au>
use vars qw(
%legal_product
);
use strict; use strict;
use lib qw(.); use lib qw(.);
use Bugzilla; use Bugzilla;
use Bugzilla::Constants; use Bugzilla::Constants;
require "CGI.pl"; require "CGI.pl";
use vars qw($vars @legal_product);
Bugzilla->login(); Bugzilla->login();
GetVersionTable(); GetVersionTable();
my $cgi = Bugzilla->cgi; my $cgi = Bugzilla->cgi;
my $product = $cgi->param('product'); my $template = Bugzilla->template;
my $product = trim($cgi->param('product') || '');
my $product_id = get_product_id($product);
if (!defined $product) { if (!$product_id || !CanEnterProduct($product)) {
# Reference to a subset of %::proddesc, which the user is allowed to see # Reference to a subset of %::proddesc, which the user is allowed to see
my %products; my %products;
...@@ -55,7 +53,7 @@ if (!defined $product) { ...@@ -55,7 +53,7 @@ if (!defined $product) {
} }
} }
else { else {
%products = %::proddesc; %products = %::proddesc;
} }
my $prodsize = scalar(keys %products); my $prodsize = scalar(keys %products);
...@@ -63,43 +61,32 @@ if (!defined $product) { ...@@ -63,43 +61,32 @@ if (!defined $product) {
ThrowUserError("no_products"); ThrowUserError("no_products");
} }
elsif ($prodsize > 1) { elsif ($prodsize > 1) {
$::vars->{'proddesc'} = \%products; $vars->{'proddesc'} = \%products;
$::vars->{'target'} = "describecomponents.cgi"; $vars->{'target'} = "describecomponents.cgi";
# If an invalid product name is given, or the user is not
# allowed to access that product, a message is displayed
# with a list of the products the user can choose from.
if ($product) {
$vars->{'message'} = "product_invalid";
$vars->{'product'} = $product;
}
print $cgi->header(); print $cgi->header();
$::template->process("global/choose-product.html.tmpl", $::vars) $template->process("global/choose-product.html.tmpl", $vars)
|| ThrowTemplateError($::template->error()); || ThrowTemplateError($template->error());
exit; exit;
} }
$product = (keys %products)[0]; $product = (keys %products)[0];
} }
# Make sure the user specified a valid product name. Note that
# if the user specifies a valid product name but is not authorized
# to access that product, they will receive a different error message
# which could enable people guessing product names to determine
# whether or not certain products exist in Bugzilla, even if they
# cannot get any other information about that product.
my $product_id = get_product_id($product);
if (!$product_id) {
ThrowUserError("invalid_product_name",
{ product => $product });
}
# Make sure the user is authorized to access this product.
CanEnterProduct($product)
|| ThrowUserError("product_access_denied");
###################################################################### ######################################################################
# End Data/Security Validation # End Data/Security Validation
###################################################################### ######################################################################
my @components; my @components;
SendSQL("SELECT name, initialowner, initialqacontact, description FROM " . SendSQL("SELECT name, initialowner, initialqacontact, description FROM " .
"components WHERE product_id = $product_id ORDER BY " . "components WHERE product_id = $product_id ORDER BY name");
"name");
while (MoreSQLData()) { while (MoreSQLData()) {
my ($name, $initialowner, $initialqacontact, $description) = my ($name, $initialowner, $initialqacontact, $description) =
FetchSQLData(); FetchSQLData();
...@@ -116,10 +103,9 @@ while (MoreSQLData()) { ...@@ -116,10 +103,9 @@ while (MoreSQLData()) {
push @components, \%component; push @components, \%component;
} }
$::vars->{'product'} = $product; $vars->{'product'} = $product;
$::vars->{'components'} = \@components; $vars->{'components'} = \@components;
print $cgi->header(); print $cgi->header();
$::template->process("reports/components.html.tmpl", $::vars) $template->process("reports/components.html.tmpl", $vars)
|| ThrowTemplateError($::template->error()); || ThrowTemplateError($template->error());
...@@ -135,6 +135,12 @@ ...@@ -135,6 +135,12 @@
<a href="editflagtypes.cgi">Back to flag types.</a> <a href="editflagtypes.cgi">Back to flag types.</a>
</p> </p>
[% ELSIF message_tag == "product_invalid" %]
[% title = "$terms.Bugzilla Component Descriptions" %]
The product <em>[% product FILTER html %]</em> does not exist
or you don't have access to it. The following is a list of the
products you can choose from.
[% ELSIF message_tag == "series_created" %] [% ELSIF message_tag == "series_created" %]
[% title = "Series Created" %] [% title = "Series Created" %]
The series <em>[% series.category FILTER html %] / The series <em>[% series.category FILTER html %] /
......
...@@ -798,10 +798,6 @@ ...@@ -798,10 +798,6 @@
Patches cannot be more than [% Param('maxpatchsize') %] KB in size. Patches cannot be more than [% Param('maxpatchsize') %] KB in size.
Try breaking your patch into several pieces. Try breaking your patch into several pieces.
[% ELSIF error == "product_access_denied" %]
[% title = "Access Denied" %]
You do not have the permissions necessary to access that product.
[% ELSIF error == "product_edit_denied" %] [% ELSIF error == "product_edit_denied" %]
[% title = "Product Edit Access Denied" %] [% title = "Product Edit Access Denied" %]
You are not permitted to edit [% terms.bugs %] in product You are not permitted to edit [% terms.bugs %] in product
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment