From: Don Armstrong Date: Thu, 1 Oct 2015 00:14:01 +0000 (-0700) Subject: Fix mbox output of bugreports to properly use filehandle X-Git-Tag: release/2.6.0~217 X-Git-Url: https://git.donarmstrong.com/?p=debbugs.git;a=commitdiff_plain;h=98422d682786dac1dd2191b60cb82584b92b73f3 Fix mbox output of bugreports to properly use filehandle Write test to actually test mbox output Closes: #800497 --- diff --git a/cgi/bugreport.cgi b/cgi/bugreport.cgi index bf1db2d..db4619d 100755 --- a/cgi/bugreport.cgi +++ b/cgi/bugreport.cgi @@ -235,6 +235,8 @@ END if ($record->{inner_file}) { push @lines, $record->{fh}->getline; push @lines, $record->{fh}->getline; + chomp $lines[0]; + chomp $lines[1]; } else { @lines = split( "\n", $record->{text}, -1 ); } @@ -243,11 +245,12 @@ END } if ( !( $lines[ 0 ] =~ m/^From / ) ) { unshift @lines, "From unknown $date"; - } + } + print $lines[0]."\n"; print map { s/^(>*From )/>$1/; $_."\n" } @lines[ 1 .. $#lines ]; if ($record->{inner_file}) { my $fh = $record->{fh}; - print <$fh>; + print $_ while (<$fh>); } } exit 0; diff --git a/t/07_bugreport.t b/t/07_bugreport.t index 78fbdc7..0366be4 100644 --- a/t/07_bugreport.t +++ b/t/07_bugreport.t @@ -1,7 +1,7 @@ # -*- mode: cperl;-*- -use Test::More tests => 3; +use Test::More tests => 6; use warnings; use strict; @@ -77,5 +77,13 @@ $mech->get_ok('http://localhost:'.$port.'/?bug=1', ok($mech->content() =~ qr/\\#1.+Submitting a bug/i, 'Title of bug is submitting a bug'); +$mech->get_ok('http://localhost:'.$port.'/?bug=1;mbox=yes', + 'Page received ok'); +ok($mech->content() =~ qr/Subject: Submitting a bug/i, + 'Subject of bug maibox is right'); +ok($mech->content() =~ qr/^From /m, + 'Starts with a From appropriately'); + + # Other tests for bugs in the page should be added here eventually