From 5f9f484fadbdc28be6b0c6b9ab0b67b6fd4d0e9c Mon Sep 17 00:00:00 2001 From: "lpsolit%gmail.com" <> Date: Wed, 20 Jul 2005 09:14:24 +0000 Subject: Bug 257767: Option to have fields in CSV files separated by semicolons instead of commas - Patch by Marc Schumann r=LpSolit a=myk --- Bugzilla/User/Setting.pm | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'Bugzilla/User/Setting.pm') 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 + +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 Description: If a user chooses to use the global default for a given -- cgit v1.2.3-24-g4f1b