From 3236120a9aca8133a7befcfb6bba101a54cea34e Mon Sep 17 00:00:00 2001 From: "mkanat%kerio.com" Date: Mon, 7 Mar 2005 13:55:34 +0000 Subject: [PATCH] Bug 283924: Move ValidateComment out of CGI.pl Patch By Max Kanat-Alexander r=LpSolit, a=justdave git-svn-id: svn://10.0.0.236/trunk@170281 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/webtools/bugzilla/Bugzilla/Bug.pm | 15 +++++++++++++++ mozilla/webtools/bugzilla/CGI.pl | 10 ---------- mozilla/webtools/bugzilla/attachment.cgi | 1 + 3 files changed, 16 insertions(+), 10 deletions(-) diff --git a/mozilla/webtools/bugzilla/Bugzilla/Bug.pm b/mozilla/webtools/bugzilla/Bugzilla/Bug.pm index b2261e1ee18..b9229d98e7f 100644 --- a/mozilla/webtools/bugzilla/Bugzilla/Bug.pm +++ b/mozilla/webtools/bugzilla/Bugzilla/Bug.pm @@ -44,6 +44,13 @@ use Bugzilla::User; use Bugzilla::Util; use Bugzilla::Error; +use base qw(Exporter); +@Bugzilla::Bug::EXPORT = qw( + ValidateComment +); + +use constant MAX_COMMENT_LENGTH => 65535; + sub fields { # Keep this ordering in sync with bugzilla.dtd my @fields = qw(bug_id alias creation_ts short_desc delta_ts @@ -585,6 +592,14 @@ sub CountOpenDependencies { return @dependencies; } +sub ValidateComment ($) { + my ($comment) = @_; + + if (defined($comment) && length($comment) > MAX_COMMENT_LENGTH) { + ThrowUserError("comment_too_long"); + } +} + sub AUTOLOAD { use vars qw($AUTOLOAD); my $attr = $AUTOLOAD; diff --git a/mozilla/webtools/bugzilla/CGI.pl b/mozilla/webtools/bugzilla/CGI.pl index d650ea08ed8..652d6c03b47 100644 --- a/mozilla/webtools/bugzilla/CGI.pl +++ b/mozilla/webtools/bugzilla/CGI.pl @@ -188,16 +188,6 @@ sub ValidateBugID { } } -sub ValidateComment { - # Make sure a comment is not too large (greater than 64K). - - my ($comment) = @_; - - if (defined($comment) && length($comment) > 65535) { - ThrowUserError("comment_too_long"); - } -} - sub PasswordForLogin { my ($login) = (@_); SendSQL("select cryptpassword from profiles where login_name = " . diff --git a/mozilla/webtools/bugzilla/attachment.cgi b/mozilla/webtools/bugzilla/attachment.cgi index 92d127e1a19..64e30f64a7f 100755 --- a/mozilla/webtools/bugzilla/attachment.cgi +++ b/mozilla/webtools/bugzilla/attachment.cgi @@ -48,6 +48,7 @@ use Bugzilla::Flag; use Bugzilla::FlagType; use Bugzilla::User; use Bugzilla::Util; +use Bugzilla::Bug; # Check whether or not the user is logged in and, if so, set the $::userid Bugzilla->login();