diff options
author | Byron Jones <bjones@mozilla.com> | 2013-07-16 19:28:22 +0200 |
---|---|---|
committer | Byron Jones <bjones@mozilla.com> | 2013-07-16 19:28:22 +0200 |
commit | 8659e7b108bf333fdd3ee763be427bf9783bc687 (patch) | |
tree | 7d91350ce70fa2158384066ef8e2e48e7deaa3dc /attachment.cgi | |
parent | cd2f1c38499004485e3a817e8835b2a0ed9266fd (diff) | |
download | bugzilla-8659e7b108bf333fdd3ee763be427bf9783bc687.tar.gz bugzilla-8659e7b108bf333fdd3ee763be427bf9783bc687.tar.xz |
Bug 888939: patches created by pasting the attachment content should use unix line endings
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'), |