Commit de177c6b authored by gerv%gerv.net's avatar gerv%gerv.net

Bug 162068 - Fix callers of ThrowUserError to use messages.html.tmpl. Patch by gerv; r=bbaetz.

parent 24ad8585
......@@ -95,10 +95,8 @@ sub init {
my $c = &::trim($F{'votes'});
if ($c ne "") {
if ($c !~ /^[0-9]*$/) {
my $htmlc = html_quote($c);
&::ThrowUserError("The <em>At least ___ votes</em> field must
be a simple number. You entered
<tt>$htmlc</tt>, which doesn't cut it.");
$vars->{'value'} = $c;
&::ThrowUserError("illegal_at_least_x_votes");
}
push(@specialchart, ["votes", "greaterthan", $c - 1]);
}
......@@ -181,9 +179,8 @@ sub init {
if (@clist) {
push(@specialchart, \@clist);
} else {
my $htmlemail = html_quote($email);
&::ThrowUserError("You must specify one or more fields in which
to search for <tt>$htmlemail</tt>.");
$vars->{'email'} = $email;
&::ThrowUserError("missing_email_type");
}
}
......@@ -192,10 +189,8 @@ sub init {
my $c = &::trim($F{'changedin'});
if ($c ne "") {
if ($c !~ /^[0-9]*$/) {
my $htmlc = &::html_quote($c);
&::ThrowUserError("The <em>changed in last ___ days</em> field
must be a simple number. You entered
<tt>$htmlc</tt>, which doesn't cut it.");
$vars->{'value'} = $c;
&::ThrowUserError("illegal_changed_in_last_x_days");
}
push(@specialchart, ["changedin",
"lessthan", $c + 1]);
......@@ -341,14 +336,10 @@ sub init {
$t = "greaterthan";
}
if ($field eq "ispatch" && $v ne "0" && $v ne "1") {
&::ThrowUserError("The only legal values for the
<em>Attachment is patch</em> field are
0 and 1.");
&::ThrowUserError("illegal_attachment_is_patch");
}
if ($field eq "isobsolete" && $v ne "0" && $v ne "1") {
&::ThrowUserError("The only legal values for the
<em>Attachment is obsolete</em> field are
0 and 1.");
&::ThrowUserError("illegal_is_obsolete");
}
$f = "$table.$field";
},
......@@ -446,11 +437,8 @@ sub init {
push(@list, "$table.keywordid = $id");
}
else {
my $htmlv = &::html_quote($v);
&::ThrowUserError("There is no keyword named<code>$htmlv
</code>. To search for keywords, consult
the <a href='describekeywords.cgi'>list
of legal keywords</a>.");
$vars->{'keyword'} = $v;
&::ThrowUserError("unknown_keyword");
}
}
my $haveawordterm;
......@@ -854,9 +842,8 @@ sub SqlifyDate {
}
my $date = str2time($str);
if (!defined($date)) {
my $htmlstr = html_quote($str);
ThrowUserError("The string <tt>$htmlstr</tt> is not a legal date.");
exit;
$vars->{'date'} = $str;
ThrowUserError("illegal_date");
}
return time2str("%Y-%m-%d %H:%M:%S", $date);
}
......
......@@ -557,12 +557,8 @@ sub CheckEmailSyntax {
my ($addr) = (@_);
my $match = Param('emailregexp');
if ($addr !~ /$match/ || $addr =~ /[\\\(\)<>&,;:"\[\] \t\r\n]/) {
ThrowUserError("The e-mail address you entered(<b>" .
html_quote($addr) . "</b>) didn't pass our syntax checking
for a legal email address. " . Param('emailregexpdesc') .
' It must also not contain any of these special characters:
<tt>\ ( ) &amp; &lt; &gt; , ; : " [ ]</tt>, or any whitespace.',
"Check e-mail address syntax");
$vars->{'addr'} = $addr;
ThrowUserError("illegal_email_address");
}
}
......@@ -616,7 +612,7 @@ sub confirm_login {
if ( defined $::FORM{"PleaseMailAPassword"} && !$userid ) {
# Ensure the new login is valid
if(!ValidateNewUser($enteredlogin)) {
ThrowUserError("That account already exists.");
ThrowUserError("account_exists");
}
my $password = InsertNewUser($enteredlogin, "");
......@@ -805,10 +801,8 @@ Set-Cookie: Bugzilla_logincookie= ; path=$cookiepath; expires=Sun, 30-Jun-80 00:
Content-type: text/html
";
ThrowUserError($::disabledreason . "<hr>" .
"If you believe your account should be restored, please " .
"send email to " . Param("maintainer") . " explaining why.",
"Your account has been disabled");
$vars->{'disabled_reason'} = $::disabledreason;
ThrowUserError("account_disabled");
}
if (!defined $nexturl || $nexturl eq "") {
......@@ -897,7 +891,7 @@ sub ThrowCodeError {
# undef as the second parameter and $unlock_tables as the third.
# The second parameter will eventually go away.
sub ThrowUserError {
($vars->{'error'}, $vars->{'title'}, my $unlock_tables) = (@_);
($vars->{'error'}, my $unlock_tables) = (@_);
SendSQL("UNLOCK TABLES") if $unlock_tables;
......
......@@ -92,21 +92,17 @@ if (!tie(%dbmcount, 'AnyDBM_File', "data/duplicates/dupes$today",
if ($!{ENOENT}) {
if (!tie(%dbmcount, 'AnyDBM_File', "data/duplicates/dupes$yesterday",
O_RDONLY, 0644)) {
$vars->{'today'} = $today;
if ($!{ENOENT}) {
ThrowUserError("There are no duplicate statistics for today " .
"($today) or yesterday.",
"Cannot find duplicate statistics");
ThrowUserError("no_dupe_stats");
} else {
ThrowUserError("There are no duplicate statistics for today " .
"($today), and an error occurred when " .
"accessing yesterday's dupes file: $!.",
"Error reading yesterday's dupes file");
$vars->{'error_msg'} = $!;
ThrowUserError("no_dupe_stats_error_yesterday");
}
}
} else {
ThrowUserError("An error occurred when accessing today ($today)'s " .
"dupes file: $!.",
"Error reading today's dupes file");
$vars->{'error_msg'} = $!;
ThrowUserError("no_dupe_stats_error_today");
}
}
......@@ -133,9 +129,10 @@ if (!tie(%before, 'AnyDBM_File', "data/duplicates/dupes$whenever",
O_RDONLY, 0644)) {
# Ignore file not found errors
if (!$!{ENOENT}) {
ThrowUserError("Can't open $changedsince days ago ($whenever)'s " .
"dupes file: $!",
"Error reading previous dupes file");
$vars->{'error_msg'} = $!;
$vars->{'changedsince'} = $changedsince;
$vars->{'whenever'} = $whenever;
ThrowUserError("no_dupe_stats_error_whenever");
}
} else {
# Calculate the deltas
......
......@@ -946,10 +946,8 @@ sub DBNameToIdAndCheck {
return $result;
}
$name = html_quote($name);
ThrowUserError("The name <tt>$name</tt> is not a valid username.
Either you misspelled it, or the person has not
registered for a Bugzilla account.");
$::vars->{'name'} = $name;
ThrowUserError("invalid_username");
}
sub get_product_id {
......
......@@ -159,8 +159,7 @@ sub CheckonComment( $ ) {
if( $ret ) {
if (!defined $::FORM{'comment'} || $::FORM{'comment'} =~ /^\s*$/) {
# No comment - sorry, action not allowed !
ThrowUserError("You have to specify a <b>comment</b> on this change.
Please give some words on the reason for your change.");
ThrowUserError("comment_required");
} else {
$ret = 0;
}
......@@ -325,13 +324,12 @@ sub CheckCanChangeField {
$qacontactid eq $whoid) {
return 1;
}
SendSQL("UNLOCK TABLES");
$oldvalue = html_quote($oldvalue);
$newvalue = html_quote($newvalue);
ThrowUserError("You tried to change the <strong>$f</strong> field
from <em>$oldvalue</em> to <em>$newvalue</em>,
but only the owner or submitter of the bug, or a
sufficiently empowered user, may change that field.");
# The user doesn't have the necessary permissions to change this field.
$vars->{'oldvalue'} = $oldvalue;
$vars->{'newvalue'} = $newvalue;
$vars->{'field'} = $f;
ThrowUserError("illegal_change", "abort");
}
# Confirm that the reporter of the current bug can access the bug we are duping to.
......@@ -563,38 +561,30 @@ if (Param("usebugaliases") && defined($::FORM{'alias'})) {
if ($alias ne "") {
# Make sure the alias isn't too long.
if (length($alias) > 20) {
ThrowUserError("Bug aliases cannot be longer than 20 characters.
Please choose a shorter alias.");
ThrowUserError("alias_too_long");
}
# Make sure the alias is unique.
my $escaped_alias = SqlQuote($alias);
$vars->{'alias'} = $alias;
SendSQL("SELECT bug_id FROM bugs WHERE alias = $escaped_alias " .
"AND bug_id != $idlist[0]");
my $id = FetchOneColumn();
if ($id) {
my $escaped_alias = html_quote($alias);
my $bug_link = GetBugLink($id, "Bug $id");
ThrowUserError("$bug_link has already taken the alias
<em>$escaped_alias</em>. Please choose another one.");
$vars->{'bug_link'} = GetBugLink($id, "Bug $id");
ThrowUserError("alias_in_use");
}
# Make sure the alias isn't just a number.
if ($alias =~ /^\d+$/) {
ThrowUserError("You gave this bug the alias <em>$alias</em>,
but aliases cannot be merely numbers, since they could
then be confused with bug IDs. Please choose another
alias containing at least one letter.");
ThrowUserError("alias_is_numeric");
}
# Make sure the alias has no commas or spaces.
if ($alias =~ /[, ]/) {
my $escaped_alias = html_quote($alias);
ThrowUserError("The alias you entered, <em>$escaped_alias</em>,
contains one or more commas or spaces. Aliases cannot contain
commas or spaces because those characters are used to separate
aliases from each other in lists. Please choose another alias
that does not contain commas and spaces.");
ThrowUserError("alias_has_comma_or_space");
}
}
......@@ -721,11 +711,9 @@ SWITCH: for ($::FORM{'knob'}) {
}
ChangeStatus('NEW');
DoComma();
if ( !defined$::FORM{'assigned_to'} ||
if (!defined$::FORM{'assigned_to'} ||
trim($::FORM{'assigned_to'}) eq "") {
ThrowUserError("You cannot reassign to a bug to nobody. Unless you
intentionally cleared out the \"Reassign bug to\"
field, " . Param("browserbugmessage"));
ThrowUserError("reassign_to_empty");
}
my $newid = DBNameToIdAndCheck(trim($::FORM{'assigned_to'}));
$::query .= "assigned_to = $newid";
......@@ -733,12 +721,10 @@ SWITCH: for ($::FORM{'knob'}) {
};
/^reassignbycomponent$/ && CheckonComment( "reassignbycomponent" ) && do {
if ($::FORM{'product'} eq $::dontchange) {
ThrowUserError("You must specify a product to help determine
the new owner of these bugs.");
ThrowUserError("need_product");
}
if ($::FORM{'component'} eq $::dontchange) {
ThrowUserError("You must specify a component whose owner
should get assigned these bugs.");
ThrowUserError("need_component");
}
if ($::FORM{'compconfirm'}) {
DoConfirm();
......@@ -786,19 +772,17 @@ SWITCH: for ($::FORM{'knob'}) {
SendSQL("SELECT bug_id FROM bugs WHERE bug_id = " . SqlQuote($num));
$num = FetchOneColumn();
if (!$num) {
ThrowUserError("You must specify a valid bug number of which this bug
is a duplicate. The bug has not been changed.")
ThrowUserError("dupe_invalid_bug_id")
}
if (!defined($::FORM{'id'}) || $num == $::FORM{'id'}) {
ThrowUserError("Nice try, $::COOKIE{'Bugzilla_login'}, but it doesn't
really make sense to mark a bug as a duplicate of itself,
does it?");
ThrowUserError("dupe_of_self_disallowed");
}
my $checkid = trim($::FORM{'id'});
SendSQL("SELECT bug_id FROM bugs where bug_id = " . SqlQuote($checkid));
$checkid = FetchOneColumn();
if (!$checkid) {
ThrowUserError("The bug id $::FORM{'id'} is invalid.");
$vars->{'bug_id'} = $checkid;
ThrowUserError("invalid_bug_id");
}
$::FORM{'comment'} .= "\n\n*** This bug has been marked as a duplicate of $num ***";
$duplicate = $num;
......@@ -812,7 +796,7 @@ SWITCH: for ($::FORM{'knob'}) {
if ($#idlist < 0) {
ThrowUserError("You apparently didn't choose any bugs to modify.");
ThrowUserError("no_bugs_chosen");
}
......@@ -826,9 +810,7 @@ if ($::FORM{'keywords'}) {
}
my $i = GetKeywordIdFromName($keyword);
if (!$i) {
ThrowUserError("Unknown keyword named <code>" . html_quote($keyword) .
"</code>. <p>The legal keyword names are
<a href=\"describekeywords.cgi\">listed here</a></p>.");
ThrowUserError("unknown_keyword");
}
if (!$keywordseen{$i}) {
push(@keywordlist, $i);
......@@ -844,8 +826,7 @@ if ($::comma eq ""
&& defined $::FORM{'masscc'} && ! $::FORM{'masscc'}
) {
if (!defined $::FORM{'comment'} || $::FORM{'comment'} =~ /^\s*$/) {
ThrowUserError("Um, you apparently did not change anything
on the selected bugs.");
ThrowUserError("bugs_not_changed");
}
}
......@@ -981,11 +962,8 @@ foreach my $id (@idlist) {
SqlQuote($oldhash{'product'}));
if ($value eq FetchOneColumn()) {
SendSQL("UNLOCK TABLES");
ThrowUserError("You must determine a target milestone for bug $id
if you are going to accept it. Part of accepting
a bug is giving an estimate of when it will be fixed.",
undef,
"abort");
$vars->{'bug_id'} = $id;
ThrowUserError("milestone_required", "abort");
}
}
if (defined $::FORM{'delta_ts'} && $::FORM{'delta_ts'} ne $delta_ts) {
......@@ -1020,9 +998,7 @@ foreach my $id (@idlist) {
next if $i eq "";
if ($id eq $i) {
ThrowUserError("You can't make a bug blocked or dependent on itself.",
undef,
"abort");
ThrowUserError("dependency_loop_single", "abort");
}
if (!exists $seen{$i}) {
push(@{$deptree{$target}}, $i);
......@@ -1064,13 +1040,9 @@ foreach my $id (@idlist) {
foreach my $i (@isect) {
$both = $both . GetBugLink($i, "#" . $i) . " ";
}
ThrowUserError(qq|Dependency loop detected!<p>
The following bug(s) would appear on both the "depends on"
and "blocks" parts of the dependency tree if these changes
are committed: $both<br>This would create a circular
dependency, which is not allowed.</p>|,
undef,
"abort");
$vars->{'both'} = $both;
ThrowUserError("dependency_loop_multi", "abort");
}
}
my $tmp = $me;
......
......@@ -62,6 +62,122 @@
[% title = "Change columns" %]
Resubmitting your query with new columns...
[% ELSIF message_tag == "account_disabled" %]
[% title = "Account Disabled" %]
[% disabledreason %]
<hr>
If you believe your account should be restored, please
send email to [% Param("maintainer") %] explaining why.
[% ELSIF message_tag == "account_exists" %]
[% title = "Account Already Exists" %]
That account already exists.
[% ELSIF message_tag == "alias_has_comma_or_space" %]
[% title = "Invalid Characters In Alias" %]
The alias you entered, <em>[% alias FILTER html %]</em>,
contains one or more commas or spaces. Aliases cannot contain
commas or spaces because those characters are used to separate
aliases from each other in lists. Please choose another alias
that does not contain commas and spaces.
[% ELSIF message_tag == "alias_in_use" %]
[% title = "Alias In Use" %]
[% bug_link %] has already taken the alias
<em>[% alias FILTER html %]</em>. Please choose another one.
[% ELSIF message_tag == "alias_is_numeric" %]
[% title = "Alias Is Numeric" %]
You tried to give this bug the alias <em>[% alias FILTER html %]</em>,
but aliases cannot be merely numbers, since they could
then be confused with bug IDs. Please choose another
alias containing at least one letter.
[% ELSIF message_tag == "alias_too_long" %]
[% title = "Alias Too Long" %]
Bug aliases cannot be longer than 20 characters.
Please choose a shorter alias.
[% ELSIF message_tag == "bugs_not_changed" %]
[% title = "Bugs Not Changed" %]
Um, you apparently did not change anything on the selected bugs.
[% ELSIF message_tag == "comment_required" %]
[% title = "Comment Required" %]
You have to specify a <b>comment</b> on this change.
Please give some words on the reason for your change.
[% ELSIF message_tag == "dependency_loop_multi" %]
[% title = "Dependency Loop Detected" %]
The following bug(s) would appear on both the "depends on"
and "blocks" parts of the dependency tree if these changes
are committed: [% both %]. This would create a circular
dependency, which is not allowed.
[% ELSIF message_tag == "dependency_loop_single" %]
[% title = "Dependency Loop Detected" %]
You can't make a bug blocked or dependent on itself.
[% ELSIF message_tag == "dupe_invalid_bug_id" %]
[% title = "Valid Bug Number Required" %]
You must specify a valid bug number of which this bug
is a duplicate. The bug has not been changed.
[% ELSIF message_tag == "dupe_of_self_disallowed" %]
[% title = "Nice Try..." %]
Nice try, [% user.login FILTER html %], but it doesn't
really make sense to mark a bug as a duplicate of itself,
does it?
[% ELSIF message_tag == "illegal_at_least_x_votes" %]
[% title = "Your Query Makes No Sense" %]
The <em>At least ___ votes</em> field must be a simple number.
You entered <tt>[% value FILTER html %]</tt>, which isn't.
[% ELSIF message_tag == "illegal_attachment_is_patch" %]
[% title = "Your Query Makes No Sense" %]
The only legal values for the <em>Attachment is patch</em> field are
0 and 1.
[% ELSIF message_tag == "illegal_change" %]
You tried to change the <strong>[% field %]</strong> field
from <em>[% oldvalue FILTER html %]</em> to
<em>[% newvalue FILTER html %]</em>,
but only the owner or submitter of the bug, or a
sufficiently empowered user, may change that field.
[% ELSIF message_tag == "illegal_changed_in_last_x_days" %]
[% title = "Your Query Makes No Sense" %]
The <em>Changed in last ___ days</em> field must be a simple number.
You entered <tt>[% value FILTER html %]</tt>, which isn't.
[% ELSIF message_tag == "illegal_date" %]
[% title = "Your Query Makes No Sense" %]
'<tt>[% date %]</tt>' is not a legal date.
[% ELSIF message_tag == "illegal_is_obsolete" %]
[% title = "Your Query Makes No Sense" %]
The only legal values for the <em>Attachment is obsolete</em> field are
0 and 1.
[% ELSIF message_tag == "invalid_bug_id" %]
[% title = "Invalid Bug ID" %]
The bug id [% bug_id FILTER html %] is invalid.
[% ELSIF message_tag == "invalid_email_address" %]
[% title = "Invalid Email Address" %]
The e-mail address you entered(<b>[% addr FILTER html %]</b>)
didn't pass our syntax checking for a legal email address.
[% Param('emailregexpdesc') %]
It must also not contain any of these special characters:
<tt>\ ( ) &amp; &lt; &gt; , ; : &quot; [ ]</tt>, or any whitespace.
[% ELSIF message_tag == "invalid_username" %]
[% title = "Invalid Username" %]
The name <tt>[% name FILTER html %]</tt> is not a valid username.
Either you misspelled it, or the person has not
registered for a Bugzilla account.
[% ELSIF message_tag == "logged_out" %]
[% title = "Logged Out" %]
[% url = "query.cgi?GoAheadAndLogIn=1" %]
......@@ -78,6 +194,45 @@
[% title = "Page not found" %]
The page you requested cannot be found.
[% ELSIF message_tag == "milestone_required" %]
[% title = "Milestone Required" %]
You must determine a target milestone for bug [% bug_id %]
if you are going to accept it. Part of accepting
a bug is giving an estimate of when it will be fixed.
[% ELSIF message_tag == "missing_email_type" %]
[% title = "Your Query Makes No Sense" %]
You must specify one or more fields in which to search for
<tt>[% email %]</tt>.
[% ELSIF message_tag == "need_component" %]
[% title = "Component Required" %]
You must specify a component to help determine the new owner of these bugs.
[% ELSIF message_tag == "need_product" %]
[% title = "Product Required" %]
You must specify a product to help determine the new owner of these bugs.
[% ELSIF message_tag == "no_bugs_chosen" %]
[% title = "No Bugs Chosen" %]
You apparently didn't choose any bugs to modify.
[% ELSIF message_tag == "no_dupe_stats" %]
[% title = "Cannot Find Duplicate Statistics" %]
There are no duplicate statistics for today ([% today %]) or yesterday.
[% ELSIF message_tag == "no_dupe_stats_error_today" %]
[% title = "Error Reading Today's Dupes File" %]
An error occurred opening today's dupes file: [% error_msg FILTER html %].
[% ELSIF message_tag == "no_dupe_stats_error_whenever" %]
[% title = "Error Reading Previous Dupes File" %]
An error occurred opening $changedsince days ago ($whenever)'s dupes file:
[% error_msg FILTER html %].
[% ELSIF message_tag == "no_dupe_stats_error_yesterday" %]
[% title = "Error Reading Yesterday's Dupes File" %]
There are no duplicate statistics for today ([% today %]), and an error
occurred opening yesterday's dupes file: [% error_msg FILTER html %].
[% ELSIF message_tag == "password_changed" %]
[% title = "Password Changed" %]
Your password has been changed.
......@@ -91,11 +246,26 @@
A token for changing your password has been emailed to you.
Follow the instructions in that email to change your password.
[% ELSIF message_tag == "reassign_to_empty" %]
[% title = "Illegal Reassignment" %]
You cannot reassign to a bug to nobody. Unless you
intentionally cleared out the "Reassign bug to"
field, [% Param("browserbugmessage") %]
[% ELSIF message_tag == "unknown_keyword" %]
[% title = "Unknown Keyword" %]
<code>[% keyword FILTER html %]</code> is not a known keyword.
The legal keyword names are <a href="describekeywords.cgi">listed here</a>.
[% ELSE %]
[%# Cope with legacy calling convention, where "message" was the string
# to print.
[%# Give sensible error if error functions are used incorrectly.
#%]
[% message_tag %]
You are using Bugzilla's error-reporting functions incorrectly. You
passed in the string '[% message_tag %]'. The correct use is to pass
in a tag, and define that tag in the file messages.html.tmpl.<br>
<br>
If you are a Bugzilla end-user seeing this message, please save this
page and send it to [% Param('maintainer') %].
[% END %]
[% END %]
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