From: Frédéric Buclin Date: Tue, 26 Oct 2010 18:20:06 +0000 (+0200) Subject: Bug 607361: Creating an attachment without a "comment" param in the URL causes an... X-Git-Tag: bugzilla-4.0rc1~15 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9d484f73e43cbe79f0417d3e4bc4896d86936a38;p=thirdparty%2Fbugzilla.git Bug 607361: Creating an attachment without a "comment" param in the URL causes an internal error a=LpSolit --- diff --git a/attachment.cgi b/attachment.cgi index 789b55fb46..d1836ca92b 100755 --- a/attachment.cgi +++ b/attachment.cgi @@ -501,6 +501,7 @@ sub insert { # Insert a comment about the new attachment into the database. my $comment = $cgi->param('comment'); + $comment = '' unless defined $comment; $bug->add_comment($comment, { isprivate => $attachment->isprivate, type => CMT_ATTACHMENT_CREATED, extra_data => $attachment->id }); @@ -636,7 +637,7 @@ sub update { # If the user submitted a comment while editing the attachment, # add the comment to the bug. Do this after having validated isprivate! my $comment = $cgi->param('comment'); - if (trim($comment)) { + if (defined $comment && trim($comment) ne '') { $bug->add_comment($comment, { isprivate => $attachment->isprivate, type => CMT_ATTACHMENT_UPDATED, extra_data => $attachment->id });