From ea7030a701bfdb503df542c3d7e814b8ea702929 Mon Sep 17 00:00:00 2001 From: "travis%sedsystems.ca" <> Date: Thu, 17 Feb 2005 00:16:35 +0000 Subject: Bug 271276 : Cannot enter negative time for 'Hours Worked' Patch by Shane H. W. Travis r=LpSolit a=justdave --- globals.pl | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) (limited to 'globals.pl') diff --git a/globals.pl b/globals.pl index 0b7d23bc2..1bd53261f 100644 --- a/globals.pl +++ b/globals.pl @@ -109,23 +109,19 @@ $::SIG{PIPE} = 'IGNORE'; sub AppendComment { my ($bugid, $who, $comment, $isprivate, $timestamp, $work_time) = @_; $work_time ||= 0; - + + if ($work_time) { + require Bugzilla::Bug; + Bugzilla::Bug::ValidateTime($work_time, "work_time"); + } + # Use the date/time we were given if possible (allowing calling code # to synchronize the comment's timestamp with those of other records). $timestamp = ($timestamp ? SqlQuote($timestamp) : "NOW()"); - + $comment =~ s/\r\n/\n/g; # Get rid of windows-style line endings. $comment =~ s/\r/\n/g; # Get rid of mac-style line endings. - # allowing negatives though so people can back out errors in time reporting - if (defined $work_time) { - # regexp verifies one or more digits, optionally followed by a period and - # zero or more digits, OR we have a period followed by one or more digits - if ($work_time !~ /^-?(?:\d+(?:\.\d*)?|\.\d+)$/) { - ThrowUserError("need_numeric_value", {}, "abort"); - } - } else { $work_time = 0 }; - if ($comment =~ /^\s*$/) { # Nothin' but whitespace return; } -- cgit v1.2.3-24-g4f1b