From: lpsolit%gmail.com <> Date: Mon, 24 Oct 2005 04:50:34 +0000 (+0000) Subject: Bug 312307: Misused Throw*Error tags in code and templates - Patch by Dennis Melentye... X-Git-Tag: bugzilla-2.20.1~112 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1ba93ef1fc9a7136581eb6d081d3cd2c7fda57ed;p=thirdparty%2Fbugzilla.git Bug 312307: Misused Throw*Error tags in code and templates - Patch by Dennis Melentyev r=LpSolit a=justdave --- diff --git a/attachment.cgi b/attachment.cgi index f87f378d54..d452322d06 100755 --- a/attachment.cgi +++ b/attachment.cgi @@ -586,7 +586,7 @@ sub get_unified_diff my ($bugid, $description, $ispatch, $thedata) = FetchSQLData(); if (!$ispatch) { $vars->{'attach_id'} = $id; - ThrowCodeError("must_be_patch"); + ThrowUserError("must_be_patch"); } # Reads in the patch, converting to unified diff in a temp file diff --git a/enter_bug.cgi b/enter_bug.cgi index ecded81dfc..3e6b741afb 100755 --- a/enter_bug.cgi +++ b/enter_bug.cgi @@ -339,10 +339,7 @@ GetVersionTable(); my $product_id = get_product_id($product); -if (0 == @{$::components{$product}}) { - ThrowUserError("no_components", {product => $product}); -} -elsif (1 == @{$::components{$product}}) { +if (1 == @{$::components{$product}}) { # Only one component; just pick it. $cgi->param('component', $::components{$product}->[0]); } diff --git a/post_bug.cgi b/post_bug.cgi index 9d92c3c989..656ae187f1 100755 --- a/post_bug.cgi +++ b/post_bug.cgi @@ -330,7 +330,7 @@ foreach my $b (grep(/^bit-\d*$/, $cgi->param())) { if ($cgi->param($b)) { my $v = substr($b, 4); detaint_natural($v) - || ThrowCodeError("group_id_invalid"); + || ThrowUserError("invalid_group_ID"); if (!GroupIsActive($v)) { # Prevent the user from adding the bug to an inactive group. # Should only happen if there is a bug in Bugzilla or the user diff --git a/report.cgi b/report.cgi index 30c7cade87..d908c77f9d 100755 --- a/report.cgi +++ b/report.cgi @@ -289,7 +289,7 @@ elsif ($action eq "plot") { $vars->{'data'} = \@image_data; } else { - ThrowUserError("unknown_action", {action => $cgi->param('action')}); + ThrowCodeError("unknown_action", {action => $cgi->param('action')}); } my $format = GetFormat("reports/report", $formatparam, $cgi->param('ctype')); diff --git a/template/en/default/global/code-error.html.tmpl b/template/en/default/global/code-error.html.tmpl index 608e9a08fe..d4aa41d712 100644 --- a/template/en/default/global/code-error.html.tmpl +++ b/template/en/default/global/code-error.html.tmpl @@ -144,11 +144,6 @@ [%+ terms.bug %] [%+ bug_id FILTER html %]. [% END %] - [% ELSIF error == "invalid_isactive_flag" %] - [% title = "Invalid isactive flag" %] - The active flag was improperly set. There may be - a problem with [% terms.Bugzilla %] or [% terms.abug %] in your browser. - [% ELSIF error == "invalid_series_id" %] [% title = "Invalid Series" %] The series_id [% series_id FILTER html %] is not valid. It may be that @@ -229,10 +224,6 @@ [%+ series.subcategory FILTER html %] / [%+ series.name FILTER html %]. - [% ELSIF error == "no_y_axis_defined" %] - No Y axis was defined when creating report. The X axis is optional, - but the Y axis is compulsory. - [% ELSIF error == "need_quipid" %] A valid quipid is needed. diff --git a/template/en/default/global/user-error.html.tmpl b/template/en/default/global/user-error.html.tmpl index f16544b5db..57df240459 100644 --- a/template/en/default/global/user-error.html.tmpl +++ b/template/en/default/global/user-error.html.tmpl @@ -274,11 +274,6 @@ [% title = "Blank Component Name Not Allowed" %] You cannot delete the component name for component '[% name FILTER html %]'. - [% ELSIF error == "component_cant_del_description" %] - [% title = "Blank Component Description Not Allowed" %] - You cannot delete the component description for - component '[% name FILTER html %]'. - [% ELSIF error == "component_name_too_long" %] [% title = "Component Name Is Too Long" %] The name of a component is limited to 64 characters. @@ -591,11 +586,6 @@ You are not authorised to edit this series. To do this, you must either be its creator, or an administrator. - [% ELSIF error == "insufficient_data" %] - [% title = "Insufficient Data" %] - None of the series you selected have any data associated with them, so a - chart cannot be plotted. - [% ELSIF error == "insufficient_data_points" %] We don't have enough data points to make a graph (yet). @@ -643,10 +633,6 @@ The context [% context FILTER html %] is invalid (must be a number, "file" or "patch"). - [% ELSIF error == "invalid_field_name" %] - [% title = "Invalid Field Name" %] - The field "[% name FILTER html %]" is invalid. - [% ELSIF error == "invalid_format" %] [% title = "Invalid Format" %] The format "[% format FILTER html %]" is invalid (must be one of @@ -992,10 +978,6 @@ the new assignee. If you did not intentionally clear out the "Reassign [% terms.bug %] to" field, [% Param("browserbugmessage") %] - [% ELSIF error == "report_access_denied" %] - [% title = "Access Denied" %] - You do not have the permissions necessary to view reports for this product. - [% ELSIF error == "require_component" %] [% title = "Component Needed" %] To file this [% terms.bug %], you must first choose a component. @@ -1105,11 +1087,6 @@ version! You must reassign those [% terms.bugs %] to another version before you can delete this one. - [% ELSIF error == "version_name_too_long" %] - [% title = "Version Name Is Too Long" %] - The name of a version is limited to 20 characters. - '[% name FILTER html %]' is too long ([% name.length %] characters). - [% ELSIF error == "version_not_specified" %] [% title = "No Version Specified" %] No version specified when trying to edit versions. @@ -1145,15 +1122,14 @@ [% title = "Wrong Token" %] That token cannot be used to change your password. + [% ELSIF error == "extern_id_conflict" %] + [% title = "Extern ID Conflict" %] + Someone with a different external ID has that address. + [% ELSIF error == "wrong_token_for_confirming_email_change" %] [% title = "Wrong Token" %] That token cannot be used to change your email address. - [% ELSIF error == "value_out_of_range" %] - [% title = "Value Out Of Range" %] - Value is out of range for field - [% field_descs.$field FILTER html %]. - [% ELSIF error == "zero_length_file" %] [% title = "File Is Empty" %] The file you are trying to attach is empty! diff --git a/token.cgi b/token.cgi index 0e07538071..3fe8e01409 100755 --- a/token.cgi +++ b/token.cgi @@ -68,11 +68,8 @@ if ($cgi->param('t')) { $::quotedtoken = SqlQuote($::token); # Make sure the token contains only valid characters in the right amount. - my $validationerror = ValidatePassword($::token); - if ($validationerror) { - ThrowUserError("token_invalid"); - } - + # Validate password will throw an error if token is invalid + ValidatePassword($::token); Bugzilla::Token::CleanTokenTable();