diff options
author | lpsolit%gmail.com <> | 2008-01-13 00:20:50 +0100 |
---|---|---|
committer | lpsolit%gmail.com <> | 2008-01-13 00:20:50 +0100 |
commit | 0e2ea68e886628033f9afeba99f90144b4f85510 (patch) | |
tree | bdb26475965046e8680130ad0daf42d1d315416a /Bugzilla | |
parent | a404e6c3e3d777f09ef2ab8100ad01a20a3c885c (diff) | |
download | bugzilla-0e2ea68e886628033f9afeba99f90144b4f85510.tar.gz bugzilla-0e2ea68e886628033f9afeba99f90144b4f85510.tar.xz |
Bug 411437: Clipping of "Free Text" fields when user enters more then 255 characters - Patch by Frédéric Buclin <LpSolit@gmail.com> r/a=mkanat
Diffstat (limited to 'Bugzilla')
-rwxr-xr-x | Bugzilla/Bug.pm | 19 | ||||
-rw-r--r-- | Bugzilla/Constants.pm | 4 | ||||
-rwxr-xr-x | Bugzilla/WebService/Bug.pm | 4 | ||||
-rwxr-xr-x | Bugzilla/WebService/Constants.pm | 1 |
4 files changed, 23 insertions, 5 deletions
diff --git a/Bugzilla/Bug.pm b/Bugzilla/Bug.pm index e9274466d..28752da46 100755 --- a/Bugzilla/Bug.pm +++ b/Bugzilla/Bug.pm @@ -148,9 +148,12 @@ sub VALIDATORS { elsif ($field->type == FIELD_TYPE_DATETIME) { $validator = \&_check_datetime_field; } - else { + elsif ($field->type == FIELD_TYPE_FREETEXT) { $validator = \&_check_freetext_field; } + else { + $validator = \&_check_default_field; + } $validators->{$field->name} = $validator; } @@ -1074,8 +1077,6 @@ sub _check_estimated_time { return $_[0]->_check_time($_[1], 'estimated_time'); } -sub _check_freetext_field { return defined $_[1] ? trim($_[1]) : ''; } - sub _check_groups { my ($invocant, $product, $group_ids) = @_; @@ -1373,6 +1374,18 @@ sub _check_datetime_field { return $date_time } +sub _check_default_field { return defined $_[1] ? trim($_[1]) : ''; } + +sub _check_freetext_field { + my ($invocant, $text) = @_; + + $text = (defined $text) ? trim($text) : ''; + if (length($text) > MAX_FREETEXT_LENGTH) { + ThrowUserError('freetext_too_long', { text => $text }); + } + return $text; +} + sub _check_multi_select_field { my ($invocant, $values, $field) = @_; return [] if !$values; diff --git a/Bugzilla/Constants.pm b/Bugzilla/Constants.pm index 3c02c3902..ee064bb85 100644 --- a/Bugzilla/Constants.pm +++ b/Bugzilla/Constants.pm @@ -149,6 +149,7 @@ use File::Basename; MAX_LEN_QUERY_NAME MAX_MILESTONE_SIZE MAX_COMPONENT_SIZE + MAX_FREETEXT_LENGTH ); @Bugzilla::Constants::EXPORT_OK = qw(contenttypes); @@ -423,6 +424,9 @@ use constant MAX_MILESTONE_SIZE => 20; # The longest component name allowed. use constant MAX_COMPONENT_SIZE => 64; +# Maximum length allowed for free text fields. +use constant MAX_FREETEXT_LENGTH => 255; + sub bz_locations { # We know that Bugzilla/Constants.pm must be in %INC at this point. # So the only question is, what's the name of the directory diff --git a/Bugzilla/WebService/Bug.pm b/Bugzilla/WebService/Bug.pm index 7148b78cb..c4361e679 100755 --- a/Bugzilla/WebService/Bug.pm +++ b/Bugzilla/WebService/Bug.pm @@ -473,8 +473,8 @@ for more details. =item 104 (Invalid Field) -One of the drop-down fields has an invalid value. The error message will -have more detail. +One of the drop-down fields has an invalid value, or a value entered in a +text field is too long. The error message will have more detail. =item 105 (Invalid Component) diff --git a/Bugzilla/WebService/Constants.pm b/Bugzilla/WebService/Constants.pm index a1ecb53ed..d641b6e70 100755 --- a/Bugzilla/WebService/Constants.pm +++ b/Bugzilla/WebService/Constants.pm @@ -65,6 +65,7 @@ use constant WS_ERROR_CODE => { alias_has_comma_or_space => 103, # Misc. bug field errors illegal_field => 104, + freetext_too_long => 104, # Component errors require_component => 105, component_name_too_long => 105, |