summaryrefslogtreecommitdiffstats
path: root/Bugzilla
diff options
context:
space:
mode:
Diffstat (limited to 'Bugzilla')
-rw-r--r--Bugzilla/User/Setting.pm23
1 files changed, 23 insertions, 0 deletions
diff --git a/Bugzilla/User/Setting.pm b/Bugzilla/User/Setting.pm
index df1ba28f8..a5ce9411f 100644
--- a/Bugzilla/User/Setting.pm
+++ b/Bugzilla/User/Setting.pm
@@ -27,6 +27,7 @@ use base qw(Exporter);
add_setting);
use Bugzilla::Error;
+use Bugzilla::Util qw{trick_taint};
###############################
### Module Initialization ###
@@ -224,6 +225,19 @@ sub legal_values {
return $self->{'legal_values'};
}
+sub validate_value {
+ my $self = shift;
+
+ if (grep(/^$_[0]$/, @{$self->legal_values()})) {
+ trick_taint($_[0]);
+ }
+ else {
+ ThrowCodeError('setting_value_invalid',
+ {'name' => $self->{'_setting_name'},
+ 'value' => $_[0]});
+ }
+}
+
sub reset_to_default {
my ($self) = @_;
@@ -346,6 +360,15 @@ Description: Returns all legal values for this setting
Params: none
Returns: A reference to an array containing all legal values
+=item C<validate_value>
+
+Description: Determines whether a value is valid for the setting
+ by checking against the list of legal values.
+ Untaints the parameter if the value is indeed valid,
+ and throws a setting_value_invalid code error if not.
+Params: An lvalue containing a candidate for a setting value
+Returns: nothing
+
=item C<reset_to_default>
Description: If a user chooses to use the global default for a given