use Debbugs::Log qw(read_log_records);
use Debbugs::CGI qw(:url :html :util);
use Debbugs::CGI::Bugreport qw(:all);
-use Debbugs::Common qw(buglog getmaintainers);
+use Debbugs::Common qw(buglog getmaintainers make_list bug_status);
use Debbugs::Packages qw(getpkgsrc);
use Debbugs::Status qw(splitpackages get_bug_status isstrongseverity);
use Debbugs::Text qw(:templates);
+use List::Util qw(max);
+
+
use CGI::Simple;
my $q = new CGI::Simple;
my $mbox = $param{'mbox'} eq 'yes';
my $mime = $param{'mime'} eq 'yes';
-my $trim_headers = ($param{trim} || ((defined $msg and $msg)?'no':'yes')) eq 'yes';
-
-my $mbox_status_message = $param{mboxstat} eq 'yes';
-my $mbox_maint = $param{mboxmaint} 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'} eq 'yes';
-my $repeatmerged = $param{'repeatmerged'} eq 'yes';
+my %bugusertags;
+my %ut;
+my %seen_users;
my $buglog = buglog($ref);
-if (not defined $buglog) {
+my $bug_status = bug_status($ref);
+if (not defined $buglog or not defined $bug_status) {
print $q->header(-status => "404 No such bug",
-type => "text/html",
-charset => 'utf-8',
exit 0;
}
-my @stat = stat $buglog;
-my $mtime = '';
-if (@stat) {
- $mtime = strftime '%a, %d %b %Y %T GMT', gmtime($stat[9]);
-}
+# the log should almost always be newer, but just in case
+my $log_mtime = +(stat $buglog)[9] || time;
+my $status_mtime = +(stat $bug_status)[9] || time;
+my $mtime = strftime '%a, %d %b %Y %T GMT', gmtime(max($status_mtime,$log_mtime));
if ($q->request_method() eq 'HEAD' and not defined($att) and not $mbox) {
print $q->header(-type => "text/html",
exit 0;
}
+for my $user (map {split /[\s*,\s*]+/} make_list($param{users}||[])) {
+ next unless length($user);
+ add_user($user,\%ut,\%bugusertags,\%seen_users);
+}
+
+if (defined $param{usertag}) {
+ for my $usertag (make_list($param{usertag})) {
+ my %select_ut = ();
+ my ($u, $t) = split /:/, $usertag, 2;
+ Debbugs::User::read_usertags(\%select_ut, $u);
+ unless (defined $t && $t ne "") {
+ $t = join(",", keys(%select_ut));
+ }
+ add_user($u,\%ut,\%bugusertags,\%seen_users);
+ push @{$param{tag}}, split /,/, $t;
+ }
+}
+
+
+my $trim_headers = ($param{trim} || ((defined $msg and $msg)?'no':'yes')) eq 'yes';
+
+my $mbox_status_message = $param{mboxstat} eq 'yes';
+my $mbox_maint = $param{mboxmaint} 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'} eq 'yes';
+my $repeatmerged = $param{'repeatmerged'} eq 'yes';
+
+
my $buglogfh;
if ($buglog =~ m/\.gz$/) {
}
-my %status = %{get_bug_status(bug=>$ref)};
+my %status = %{get_bug_status(bug=>$ref,
+ bugusertags => \%bugusertags,
+ )};
my @records;
eval{
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";
+ print $q->header(-type => "text/plain",
+ content_disposition => qq(attachment; filename="bug_${ref}.mbox"),
+ (length $mtime)?(-last_modified => $mtime):(),
+ );
}
else {
$msg_num++;
- print qq(Content-Disposition: attachment; filename="bug_${ref}_message_${msg_num}.mbox"\n);
- print "Content-Type: message/rfc822\n\n";
+ print $q->header(-type => "message/rfc822",
+ content_disposition => qq(attachment; filename="bug_${ref}_message_${msg_num}.mbox"),
+ (length $mtime)?(-last_modified => $mtime):(),
+ );
}
if ($mbox_status_message and @records > 1) {
my $status_message='';
msg_num => $msg_num,
att => $att,
msg => $msg,
+ trim_headers => $trim_headers,
);
exit 0;
}
my @packages = splitpackages($status{package});
foreach my $pkg (@packages) {
- $package{$pkg} = {maintainer => exists($maintainer{$pkg}) ? $maintainer{$pkg} : '(unknown)',
- source => exists($pkgsrc{$pkg}) ? $pkgsrc{$pkg} : '(unknown)',
- package => $pkg,
- };
+ if ($pkg =~ /^src\:/) {
+ my ($srcpkg) = $pkg =~ /^src:(.*)/;
+ $package{$pkg} = {maintainer => exists($maintainer{$srcpkg}) ? $maintainer{$srcpkg} : '(unknown)',
+ source => $srcpkg,
+ package => $pkg,
+ is_source => 1,
+ };
+ }
+ else {
+ $package{$pkg} = {maintainer => exists($maintainer{$pkg}) ? $maintainer{$pkg} : '(unknown)',
+ exists($pkgsrc{$pkg}) ? (source => $pkgsrc{$pkg}) : (),
+ package => $pkg,
+ };
+ }
}
# fixup various bits of the status
log => $log,
bug_num => $ref,
version_graph => $version_graph,
+ msg => $msg,
isstrongseverity => \&Debbugs::Status::isstrongseverity,
html_escape => \&Debbugs::CGI::html_escape,
looks_like_number => \&Scalar::Util::looks_like_number,