X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=cgi%2Fbugreport.cgi;h=7dd91d4431d02b83ac3fba17587c4ba753a5d640;hb=9fec47a68c31685d64b3f520632d287dba998d53;hp=fc88d5e70be42522683d91cfd17a5993c87d5d12;hpb=609b02a40d1f4231507eb7c21ac2bfe741af53e7;p=debbugs.git diff --git a/cgi/bugreport.cgi b/cgi/bugreport.cgi index fc88d5e..7dd91d4 100755 --- a/cgi/bugreport.cgi +++ b/cgi/bugreport.cgi @@ -2,31 +2,24 @@ package debbugs; +use warnings; use strict; - -if (defined $ENV{REMOTE_ADDR} and $ENV{REMOTE_ADDR} =~ m/^(72\.17\.168\.57|60\.238\.143\.248|61\.224\.27\.141|146\.82\.138\.7|61\.214\.28\.119|84\.189\.46\.3|82\.124\.165\.25|220\.181\.26\.108|220\.95\.221\.\d+|82\.120\.77\.220|80\.68\.89\.71|66\.227\.249\.188|194\.46\.224\.153|66\.246\.72\.81|60\.42\.181\.163)$/) { - print "Content-Type: text/html\n\nGo away."; - sleep(5); - exit 0; -} - use POSIX qw(strftime tzset); use MIME::Parser; use MIME::Decoder; use IO::Scalar; use IO::File; +use Debbugs::Config qw(:globals); #require '/usr/lib/debbugs/errorlib'; require './common.pl'; -require '/etc/debbugs/config'; require '/etc/debbugs/text'; -use vars(qw($gEmailDomain $gHTMLTail $gSpoolDir $gWebDomain)); - # for read_log_records use Debbugs::Log; -use Debbugs::MIME qw(convert_to_utf8 decode_rfc1522); +use Debbugs::MIME qw(convert_to_utf8 decode_rfc1522 create_mime_message); +use Debbugs::CGI qw(:url :html version_url); use Scalar::Util qw(looks_like_number); @@ -48,6 +41,11 @@ my $mime = ($param{'mime'} || 'yes') eq 'yes'; my $trim_headers = ($param{trim} || ($msg?'no':'yes')) eq 'yes'; +my $mbox_status_message = ($param{mboxstat}||'no') eq 'yes'; +my $mbox_maint = ($param{mboxmaint}||'no') eq 'yes'; +$mbox = 1 if $mbox_status_message or $mbox_maint; + + # Not used by this script directly, but fetch these so that pkgurl() and # friends can propagate them correctly. my $archive = ($param{'archive'} || 'no') eq 'yes'; @@ -182,10 +180,7 @@ my $showseverity; my $tpack; my $tmain; -$ENV{"TZ"} = 'UTC'; -tzset(); - -my $dtime = strftime "%a, %e %b %Y %T UTC", localtime; +my $dtime = strftime "%a, %e %b %Y %T UTC", gmtime; $tail_html = $debbugs::gHTMLTail; $tail_html =~ s/SUBSTITUTE_DTIME/$dtime/; @@ -280,6 +275,12 @@ if (@{$status{fixed_versions}}) { $fixedtext .= ' by ' . htmlsanit(decode_rfc1522($status{done})); } push @descstates, $fixedtext; + push @descstates, 'Version Graph}; + } elsif (length($status{done})) { push @descstates, "Done: ".htmlsanit(decode_rfc1522($status{done})); } elsif (length($status{forwarded})) { @@ -363,30 +364,6 @@ sub handle_email_message{ } -=head2 bug_links - - bug_links($one_bug); - bug_links($starting_bug,$stoping_bugs,); - -Creates a set of links to bugs, starting with bug number -$starting_bug, and finishing with $stoping_bug; if only one bug is -passed, makes a link to only a single bug. - -The content of the link is the bug number. - -=cut - -sub bug_links{ - my ($start,$stop,$query_arguments) = @_; - $stop = $stop || $start; - $query_arguments ||= ''; - my @output; - for my $bug ($start..$stop) { - push @output,'$bug); - } - return join(', ',@output); -} - =head2 handle_record push @log, handle_record($record,$ref,$msg_num); @@ -403,6 +380,7 @@ sub handle_record{ my $output = ''; local $_ = $record->{type}; if (/html/) { + my $class = $record->{text} =~ /^(?:Acknowledgement|Reply|Information|Report|Notification)/ ? 'infmessage':'msgreceived'; $output .= decode_rfc1522($record->{text}); # Link to forwarded http:// urls in the midst of the report # (even though these links already exist at the top) @@ -411,13 +389,17 @@ sub handle_record{ $output =~ s{(Bug )(\d+)( cloned as bugs? )(\d+)(?:\-(\d+)|)}{$1.bug_links($2).$3.bug_links($4,$5)}eo; # Add links to merged bugs $output =~ s{(?<=Merged )([\d\s]+)(?=\.)}{join(' ',map {bug_links($_)} (split /\s+/, $1))}eo; + # Add links to blocked bugs + $output =~ s{(?<=Blocking bugs)(?:(of )(\d+))?( (?:added|set to|removed):\s+)([\d\s\,]+)} + {(defined $2?$1.bug_links($2):'').$3. + join(' ',map {bug_links($_)} (split /\,?\s+/, $4))}eo; # Add links to reassigned packages $output =~ s{(Bug reassigned from package \`)([^\']+)(' to \`)([^\']+)(')} {$1.q($2).$3.q($4).$5}eo; $output .= 'Full text and rfc822 format available.'; - $output = "
\n" . $output . "
\n"; + $output = qq(

\n\n) . $output . "
\n"; } elsif (/recips/) { my ($msg_id) = $record->{text} =~ /^Message-Id:\s+<(.+)>/im; @@ -427,6 +409,7 @@ sub handle_record{ elsif (defined $msg_id) { $$seen_msg_ids{$msg_id} = 1; } + $output .= qq(
\n); $output .= 'View this message in rfc822 format'; $output .= handle_email_message($record->{text}, ref => $bug_number, @@ -446,7 +429,7 @@ sub handle_record{ } # Incomming Mail Message my ($received,$hostname) = $record->{text} =~ m/Received: \(at (\S+)\) by (\S+)\;/; - $output .= qq|

Message received at |. + $output .= qq|


Message received at |. htmlsanit("$received\@$hostname") . q| (full text'.q|, mbox)'.":

\n"; $output .= handle_email_message($record->{text}, ref => $bug_number, @@ -468,6 +451,7 @@ if (looks_like_number($msg) and ($msg-1) <= $#records) { } my @log; if ( $mbox ) { + my $date = strftime "%a %b %d %T %Y", localtime; if (@records > 1) { print qq(Content-Disposition: attachment; filename="bug_${ref}.mbox"\n); print "Content-Type: text/plain\n\n"; @@ -477,9 +461,49 @@ if ( $mbox ) { print qq(Content-Disposition: attachment; filename="bug_${ref}_message_${msg_num}.mbox"\n); print "Content-Type: message/rfc822\n\n"; } + if ($mbox_status_message and @records > 1) { + my $status_message=''; + my @status_fields = (retitle => 'subject', + package => 'package', + submitter => 'originator', + severity => 'severity', + tag => 'tags', + owner => 'owner', + blocks => 'blocks', + forward => 'forward', + ); + my ($key,$value); + while (($key,$value) = splice(@status_fields,0,2)) { + if (defined $status{$value} and length $status{$value}) { + $status_message .= qq($key $ref $status{$value}\n); + } + } + print STDOUT qq(From unknown $date\n), + create_mime_message([From => "$debbugs::gBug#$ref <$ref\@$debbugs::gEmailDomain>", + To => "$debbugs::gBug#$ref <$ref\@$debbugs::gEmailDomain>", + Subject => "Status: $status{subject}", + "Reply-To" => "$debbugs::gBug#$ref <$ref\@$debbugs::gEmailDomain>", + ], + <{type} !~ /^(?:recips|incoming-recv)$/; - next if not $boring and $record->{type} eq 'recips' and @records > 1; + my $wanted_type = $mbox_maint?'recips':'incoming-recv'; + # 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}; + $seen_message_ids{$msg_id} = 1; + next if $msg_id =~/handler\..+\.ack(?:info)?\@/; + $record_wanted_anyway = 1 if $record->{text} =~ /^Received: \(at control\)/; + next if not $boring and $record->{type} ne $wanted_type and not $record_wanted_anyway and @records > 1; my @lines = split( "\n", $record->{text}, -1 ); if ( $lines[ 1 ] =~ m/^From / ) { my $tmp = $lines[ 0 ]; @@ -487,7 +511,6 @@ if ( $mbox ) { $lines[ 1 ] = $tmp; } if ( !( $lines[ 0 ] =~ m/^From / ) ) { - my $date = strftime "%a %b %d %T %Y", localtime; unshift @lines, "From unknown $date"; } map { s/^(>*From )/>$1/ } @lines[ 1 .. $#lines ]; @@ -510,7 +533,7 @@ else { } @log = reverse @log if $reverse; -$log = join('
',@log); +$log = join("\n",@log); print "Content-Type: text/html; charset=utf-8\n\n"; @@ -520,19 +543,46 @@ my $title = htmlsanit($status{subject}); my $dummy2 = $debbugs::gWebHostBugDir; print "\n"; -print "\n" . - "$short - $title - $debbugs::gProject $debbugs::gBug report logs\n" . - ''. - "" . - "\n" . - '' . - "\n"; +print < +$short - $title - $debbugs::gProject $debbugs::gBug report logs + + + + + +END print "

" . "$debbugs::gProject $debbugs::gBug report logs - $short" . "
" . $title . "

\n"; print "$descriptivehead\n"; -printf "

View this report as an mbox folder.

\n", bugurl($ref, "mbox"); -print "
"; +print qq(

Reply ), + qq(or subscribe ), + qq(to this bug.

\n); +print qq(

Show useless messages

); +printf qq(

View this report as an mbox folder, ). + qq(status mbox, maintainer mbox

\n), + html_escape(bug_url($ref, mbox=>'yes')), + html_escape(bug_url($ref, mbox=>'yes',mboxstatus=>'yes')), + html_escape(bug_url($ref, mbox=>'yes',mboxmaint=>'yes')); print "$log"; print "
"; print "

Send a report that this bug log contains spam.

\n
\n";