diff options
Diffstat (limited to 'attachment.cgi')
-rwxr-xr-x | attachment.cgi | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/attachment.cgi b/attachment.cgi index b5c0f8efe..350cf91f1 100755 --- a/attachment.cgi +++ b/attachment.cgi @@ -542,13 +542,23 @@ sub insert { # Must be called before create() as it may alter $cgi->param('ispatch'). my $content_type = Bugzilla::Attachment::get_content_type(); - # Get the filehandle of the attachment. - my $data_fh = $cgi->upload('data'); + # Get the attach data + my $data = scalar($cgi->param('attach_text')); + if ($data) { + # Convert to unix line-endings if pasting a patch + if (scalar($cgi->param('ispatch'))) { + $data =~ s/[\012\015]{1,2}/\012/g; + } + } + else { + # Get the filehandle of the attachment. + $data = $cgi->upload('data'); + } my $attachment = Bugzilla::Attachment->create( {bug => $bug, creation_ts => $timestamp, - data => scalar $cgi->param('attach_text') || $data_fh, + data => $data, description => scalar $cgi->param('description'), filename => $cgi->param('attach_text') ? "file_$bugid.txt" : scalar $cgi->upload('data'), ispatch => scalar $cgi->param('ispatch'), |