]> git.donarmstrong.com Git - debbugs.git/commitdiff
Fix mbox output of bugreports to properly use filehandle
authorDon Armstrong <don@donarmstrong.com>
Thu, 1 Oct 2015 00:14:01 +0000 (17:14 -0700)
committerDon Armstrong <don@donarmstrong.com>
Thu, 1 Oct 2015 00:14:01 +0000 (17:14 -0700)
Write test to actually test mbox output

Closes: #800497
cgi/bugreport.cgi
t/07_bugreport.t

index bf1db2d3ce3fa976945fdcbb6e9e4cdbf19c44e6..db4619d85d7fb3047978e153a41fa1bce131f51d 100755 (executable)
@@ -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;
index 78fbdc74b4cd3742c30dd088ea1555eeea9492cb..0366be41b9c5b72a5229c94f0aafe4a0bb01480e 100644 (file)
@@ -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/\<title\>\#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