X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=cgi%2Fbugreport.cgi;h=55617ae1f2a9abcd186bbf5007576a2e4572670e;hb=bef92e64a60dbdb4df7abb60dc020d7c68f0355b;hp=8692146485297e70cf3bd9e83f255c16056d028e;hpb=b7e8647009f0aad9689e88d13a13341b5e7ad83a;p=debbugs.git diff --git a/cgi/bugreport.cgi b/cgi/bugreport.cgi index 8692146..55617ae 100755 --- a/cgi/bugreport.cgi +++ b/cgi/bugreport.cgi @@ -1,8 +1,16 @@ -#!/usr/bin/perl -wT +#!/usr/bin/perl use warnings; use strict; +# Sanitize environent for taint +BEGIN{ + delete @ENV{qw(IFS CDPATH ENV BASH_ENV)}; +} + +# STDOUT should be using the utf8 io layer +binmode(STDOUT,':utf8'); + use POSIX qw(strftime); use MIME::Parser; use MIME::Decoder; @@ -163,6 +171,7 @@ if (defined($msg) and ($msg-1) <= $#records) { } my @log; if ( $mbox ) { + binmode(STDOUT,":raw"); my $date = strftime "%a %b %d %T %Y", localtime; if (@records > 1) { print $q->header(-type => "text/plain", @@ -215,11 +224,11 @@ END # we want to include control messages anyway my $record_wanted_anyway = 0; my ($msg_id) = $record->{text} =~ /^Message-Id:\s+<(.+)>/im; - next if exists $seen_message_ids{$msg_id}; - next if $msg_id =~/handler\..+\.ack(?:info|done)?\@/; + next if defined $msg_id and exists $seen_message_ids{$msg_id}; + next if defined $msg_id and $msg_id =~/handler\..+\.ack(?:info|done)?\@/; $record_wanted_anyway = 1 if $record->{text} =~ /^Received: \(at control\)/; next if not $boring and not $record->{type} eq $wanted_type and not $record_wanted_anyway and @records > 1; - $seen_message_ids{$msg_id} = 1; + $seen_message_ids{$msg_id} = 1 if defined $msg_id; my @lines = split( "\n", $record->{text}, -1 ); if ( $lines[ 1 ] =~ m/^From / ) { my $tmp = $lines[ 0 ]; @@ -237,6 +246,7 @@ END else { if (defined $att and defined $msg and @records) { + binmode(STDOUT,":raw"); $msg_num++; print handle_email_message($records[0]->{text}, ref => $ref,