]> git.donarmstrong.com Git - debbugs.git/blob - cgi/bugreport.cgi
* Add html template directory
[debbugs.git] / cgi / bugreport.cgi
1 #!/usr/bin/perl -wT
2
3 use warnings;
4 use strict;
5
6 use POSIX qw(strftime tzset);
7 use MIME::Parser;
8 use MIME::Decoder;
9 use IO::Scalar;
10 use IO::File;
11
12 use Debbugs::Config qw(:globals :text);
13
14 # for read_log_records
15 use Debbugs::Log qw(read_log_records);
16 use Debbugs::MIME qw(convert_to_utf8 decode_rfc1522 create_mime_message);
17 use Debbugs::CGI qw(:url :html :util);
18 use Debbugs::Common qw(buglog getmaintainers);
19 use Debbugs::Packages qw(getpkgsrc);
20 use Debbugs::Status qw(splitpackages get_bug_status isstrongseverity);
21
22 use Scalar::Util qw(looks_like_number);
23 use CGI::Simple;
24 my $q = new CGI::Simple;
25
26 my %param = cgi_parameters(query => $q,
27                            single => [qw(bug msg att boring terse),
28                                       qw(reverse mbox mime trim),
29                                       qw(mboxstat mboxmaint archive),
30                                       qw(repeatmerged)
31                                      ],
32                            default => {msg       => '',
33                                        boring    => 'no',
34                                        terse     => 'no',
35                                        reverse   => 'no',
36                                        mbox      => 'no',
37                                        mime      => 'no',
38                                        mboxstat  => 'no',
39                                        mboxmaint => 'no',
40                                        archive   => 'no',
41                                        repeatmerged => 'yes',
42                                       },
43                           );
44 # This is craptacular.
45
46 my $tail_html;
47
48 my $ref = $param{bug} or quitcgi("No bug number");
49 $ref =~ /(\d+)/ or quitcgi("Invalid bug number");
50 $ref = $1;
51 my $short = "#$ref";
52 my $msg = $param{'msg'};
53 my $att = $param{'att'};
54 my $boring = $param{'boring'} eq 'yes';
55 my $terse = $param{'terse'} eq 'yes';
56 my $reverse = $param{'reverse'} eq 'yes';
57 my $mbox = $param{'mbox'} eq 'yes';
58 my $mime = $param{'mime'} eq 'yes';
59
60 my $trim_headers = ($param{trim} || ($msg?'no':'yes')) eq 'yes';
61
62 my $mbox_status_message = $param{mboxstat} eq 'yes';
63 my $mbox_maint = $param{mboxmaint} eq 'yes';
64 $mbox = 1 if $mbox_status_message or $mbox_maint;
65
66
67 # Not used by this script directly, but fetch these so that pkgurl() and
68 # friends can propagate them correctly.
69 my $archive = $param{'archive'} eq 'yes';
70 my $repeatmerged = $param{'repeatmerged'} eq 'yes';
71
72 my $buglog = buglog($ref);
73
74 if (defined $ENV{REQUEST_METHOD} and $ENV{REQUEST_METHOD} eq 'HEAD' and not defined($att) and not $mbox) {
75     print "Content-Type: text/html; charset=utf-8\n";
76     my @stat = stat $buglog;
77     if (@stat) {
78         my $mtime = strftime '%a, %d %b %Y %T GMT', gmtime($stat[9]);
79         print "Last-Modified: $mtime\n";
80     }
81     print "\n";
82     exit 0;
83 }
84
85 sub display_entity {
86     my $entity = shift;
87     my $ref = shift;
88     my $top = shift;
89     my $xmessage = shift;
90     my $this = shift;
91     my $attachments = shift;
92
93     my $head = $entity->head;
94     my $disposition = $head->mime_attr('content-disposition');
95     $disposition = 'inline' if not defined $disposition or $disposition eq '';
96     my $type = $entity->effective_type;
97     my $filename = $entity->head->recommended_filename;
98     $filename = '' unless defined $filename;
99     $filename = decode_rfc1522($filename);
100
101     if ($top and not $terse) {
102          my $header = $entity->head;
103          $$this .= "<pre class=\"headers\">\n";
104          if ($trim_headers) {
105               my @headers;
106               foreach (qw(From To Cc Subject Date)) {
107                    my $head_field = $head->get($_);
108                    next unless defined $head_field and $head_field ne '';
109                    push @headers, qq(<b>$_:</b> ) . html_escape(decode_rfc1522($head_field));
110               }
111               $$this .= join(qq(), @headers) unless $terse;
112          } else {
113               $$this .= html_escape(decode_rfc1522($entity->head->stringify));
114          }
115          $$this .= "</pre>\n";
116     }
117
118     unless (($top and $type =~ m[^text(?:/plain)?(?:;|$)]) or
119             ($type =~ m[^multipart/])) {
120         push @$attachments, $entity;
121         my @dlargs = ($ref, msg=>$xmessage, att=>$#$attachments);
122         push @dlargs, (filename=>$filename) if $filename ne '';
123         my $printname = $filename;
124         $printname = 'Message part ' . ($#$attachments + 1) if $filename eq '';
125         $$this .= '<pre class="mime">[<a href="' . html_escape(bug_url(@dlargs)) . qq{">$printname</a> } .
126                   "($type, $disposition)]</pre>\n";
127
128         if ($msg and defined($att) and $att == $#$attachments) {
129             my $head = $entity->head;
130             chomp(my $type = $entity->effective_type);
131             my $body = $entity->stringify_body;
132             print "Content-Type: $type";
133             my ($charset) = $head->get('Content-Type:') =~ m/charset\s*=\s*\"?([\w-]+)\"?/i;
134             print qq(; charset="$charset") if defined $charset;
135             print "\n";
136             if ($filename ne '') {
137                 my $qf = $filename;
138                 $qf =~ s/"/\\"/g;
139                 $qf =~ s[.*/][];
140                 print qq{Content-Disposition: inline; filename="$qf"\n};
141             }
142             print "\n";
143             my $decoder = new MIME::Decoder($head->mime_encoding);
144             $decoder->decode(new IO::Scalar(\$body), \*STDOUT);
145             exit(0);
146         }
147     }
148
149     return if not $top and $disposition eq 'attachment' and not defined($att);
150     return unless ($type =~ m[^text/?] and
151                    $type !~ m[^text/(?:html|enriched)(?:;|$)]) or
152                   $type =~ m[^application/pgp(?:;|$)] or
153                   $entity->parts;
154
155     if ($entity->is_multipart) {
156         my @parts = $entity->parts;
157         foreach my $part (@parts) {
158             display_entity($part, $ref, 0, $xmessage,
159                            $$this, @$attachments);
160             $$this .= "\n";
161         }
162     } elsif ($entity->parts) {
163         # We must be dealing with a nested message.
164         $$this .= "<blockquote>\n";
165         my @parts = $entity->parts;
166         foreach my $part (@parts) {
167             display_entity($part, $ref, 1, $xmessage,
168                            $$this, @$attachments);
169             $$this .= "\n";
170         }
171         $$this .= "</blockquote>\n";
172     } else {
173          if (not $terse) {
174               my $content_type = $entity->head->get('Content-Type:') || "text/html";
175               my ($charset) = $content_type =~ m/charset\s*=\s*\"?([\w-]+)\"?/i;
176               my $body = $entity->bodyhandle->as_string;
177               $body = convert_to_utf8($body,$charset) if defined $charset;
178               $body = html_escape($body);
179               # Attempt to deal with format=flowed
180               if ($content_type =~ m/format\s*=\s*\"?flowed\"?/i) {
181                    $body =~ s{^\ }{}mgo;
182                    # we ignore the other things that you can do with
183                    # flowed e-mails cause they don't really matter.
184               }
185               # Add links to URLs
186               $body =~ s,((ftp|http|https)://[\S~-]+?/?)((\&gt\;)?[)]?[']?[:.\,]?(\s|$)),<a href=\"$1\">$1</a>$3,go;
187               # Add links to bug closures
188               $body =~ s[(closes:\s*(?:bug)?\#?\s?\d+(?:,?\s*(?:bug)?\#?\s?\d+)*)
189                         ][my $temp = $1; $temp =~ s{(\d+)}{qq(<a href=").html_escape(bug_url($1)).qq(">$1</a>)}ge; $temp;]gxie;
190               $$this .= qq(<pre class="message">$body</pre>\n);
191          }
192     }
193 }
194
195 my $buglogfh;
196 if ($buglog =~ m/\.gz$/) {
197     my $oldpath = $ENV{'PATH'};
198     $ENV{'PATH'} = '/bin:/usr/bin';
199     $buglogfh = new IO::File "zcat $buglog |" or &quitcgi("open log for $ref: $!");
200     $ENV{'PATH'} = $oldpath;
201 } else {
202     $buglogfh = new IO::File "<$buglog" or &quitcgi("open log for $ref: $!");
203 }
204
205
206 my @records;
207 eval{
208      @records = read_log_records($buglogfh);
209 };
210 if ($@) {
211      quitcgi("Bad bug log for $gBug $ref. Unable to read records: $@");
212 }
213 undef $buglogfh;
214
215 =head2 handle_email_message
216
217      handle_email_message($record->{text},
218                           ref        => $bug_number,
219                           msg_number => $msg_number,
220                          );
221
222 Returns a decoded e-mail message and displays entities/attachments as
223 appropriate.
224
225
226 =cut
227
228 sub handle_email_message{
229      my ($email,%options) = @_;
230
231      my $output = '';
232      my $parser = new MIME::Parser;
233      # Because we are using memory, not tempfiles, there's no need to
234      # clean up here like in Debbugs::MIME
235      $parser->tmp_to_core(1);
236      $parser->output_to_core(1);
237      my $entity = $parser->parse_data( $email);
238      my @attachments = ();
239      display_entity($entity, $options{ref}, 1, $options{msg_number}, $output, @attachments);
240      return $output;
241
242 }
243
244 =head2 handle_record
245
246      push @log, handle_record($record,$ref,$msg_num);
247
248 Deals with a record in a bug log as returned by
249 L<Debbugs::Log::read_log_records>; returns the log information that
250 should be output to the browser.
251
252 =cut
253
254 sub handle_record{
255      my ($record,$bug_number,$msg_number,$seen_msg_ids) = @_;
256
257      my $output = '';
258      local $_ = $record->{type};
259      if (/html/) {
260           my ($time) = $record->{text} =~ /<!--\s+time:(\d+)\s+-->/;
261           my $class = $record->{text} =~ /^<strong>(?:Acknowledgement|Reply|Information|Report|Notification)/ ? 'infmessage':'msgreceived';
262           $output .= decode_rfc1522($record->{text});
263           # Link to forwarded http:// urls in the midst of the report
264           # (even though these links already exist at the top)
265           $output =~ s,((?:ftp|http|https)://[\S~-]+?/?)([\)\'\:\.\,]?(?:\s|\.<|$)),<a href=\"$1\">$1</a>$2,go;
266           # Add links to the cloned bugs
267           $output =~ s{(Bug )(\d+)( cloned as bugs? )(\d+)(?:\-(\d+)|)}{$1.bug_links($2).$3.bug_links($4,$5)}eo;
268           # Add links to merged bugs
269           $output =~ s{(?<=Merged )([\d\s]+)(?=\.)}{join(' ',map {bug_links($_)} (split /\s+/, $1))}eo;
270           # Add links to blocked bugs
271           $output =~ s{(?<=Blocking bugs)(?:( of )(\d+))?( (?:added|set to|removed):\s+)([\d\s\,]+)}
272                       {(defined $2?$1.bug_links($2):'').$3.
273                             join(' ',map {bug_links($_)} (split /\,?\s+/, $4))}eo;
274           # Add links to reassigned packages
275           $output =~ s{(Bug reassigned from package \`)([^']+?)((?:'|\&\#39;) to \`)([^']+?)((?:'|\&\#39;))}
276           {$1.q(<a href=").html_escape(pkg_url(pkg=>$2)).qq(">$2</a>).$3.q(<a href=").html_escape(pkg_url(pkg=>$4)).qq(">$4</a>).$5}eo;
277           if (defined $time) {
278                $output .= ' ('.strftime('%a, %d %b %Y %T GMT',gmtime($time)).') ';
279           }
280           $output .= '<a href="' . html_escape(bug_url($ref, msg => ($msg_number+1))) . '">Full text</a> and <a href="' .
281                html_escape(bug_url($ref, msg => ($msg_number+1), mbox => 'yes')) . '">rfc822 format</a> available.';
282
283           $output = qq(<div class="$class"><hr>\n<a name="$msg_number"></a>\n) . $output . "</div>\n";
284      }
285      elsif (/recips/) {
286           my ($msg_id) = $record->{text} =~ /^Message-Id:\s+<(.+)>/im;
287           if (defined $msg_id and exists $$seen_msg_ids{$msg_id}) {
288                return ();
289           }
290           elsif (defined $msg_id) {
291                $$seen_msg_ids{$msg_id} = 1;
292           }
293           $output .= qq(<hr><p class="msgreceived"><a name="$msg_number"></a>\n);
294           $output .= 'View this message in <a href="' . html_escape(bug_url($ref, msg=>$msg_number, mbox=>'yes')) . '">rfc822 format</a></p>';
295           $output .= handle_email_message($record->{text},
296                                     ref        => $bug_number,
297                                     msg_number => $msg_number,
298                                    );
299      }
300      elsif (/autocheck/) {
301           # Do nothing
302      }
303      elsif (/incoming-recv/) {
304           my ($msg_id) = $record->{text} =~ /^Message-Id:\s+<(.+)>/im;
305           if (defined $msg_id and exists $$seen_msg_ids{$msg_id}) {
306                return ();
307           }
308           elsif (defined $msg_id) {
309                $$seen_msg_ids{$msg_id} = 1;
310           }
311           # Incomming Mail Message
312           my ($received,$hostname) = $record->{text} =~ m/Received: \(at (\S+)\) by (\S+)\;/;
313           $output .= qq|<hr><p class="msgreceived"><a name="$msg_number"></a><a name="msg$msg_number"></a><a href="#$msg_number">Message #$msg_number</a> received at |.
314                html_escape("$received\@$hostname") .
315                     q| (<a href="| . html_escape(bug_url($ref, msg=>$msg_number)) . '">full text</a>'.
316                          q|, <a href="| . html_escape(bug_url($ref, msg=>$msg_number,mbox=>'yes')) .'">mbox</a>)'.":</p>\n";
317           $output .= handle_email_message($record->{text},
318                                     ref        => $bug_number,
319                                     msg_number => $msg_number,
320                                    );
321      }
322      else {
323           die "Unknown record type $_";
324      }
325      return $output;
326 }
327
328 my $log='';
329 my $msg_num = 0;
330 my $skip_next = 0;
331 if (looks_like_number($msg) and ($msg-1) <= $#records) {
332      @records = ($records[$msg-1]);
333      $msg_num = $msg - 1;
334 }
335 my @log;
336 if ( $mbox ) {
337      my $date = strftime "%a %b %d %T %Y", localtime;
338      if (@records > 1) {
339           print qq(Content-Disposition: attachment; filename="bug_${ref}.mbox"\n);
340           print "Content-Type: text/plain\n\n";
341      }
342      else {
343           $msg_num++;
344           print qq(Content-Disposition: attachment; filename="bug_${ref}_message_${msg_num}.mbox"\n);
345           print "Content-Type: message/rfc822\n\n";
346      }
347      if ($mbox_status_message and @records > 1) {
348           my $status_message='';
349           my @status_fields = (retitle   => 'subject',
350                                package   => 'package',
351                                submitter => 'originator',
352                                severity  => 'severity',
353                                tag       => 'tags',
354                                owner     => 'owner',
355                                blocks    => 'blocks',
356                                forward   => 'forward',
357                               );
358           my ($key,$value);
359           while (($key,$value) = splice(@status_fields,0,2)) {
360                if (defined $status{$value} and length $status{$value}) {
361                     $status_message .= qq($key $ref $status{$value}\n);
362                }
363           }
364           print STDOUT qq(From unknown $date\n),
365                create_mime_message([From       => "$gBug#$ref <$ref\@$gEmailDomain>",
366                                     To         => "$gBug#$ref <$ref\@$gEmailDomain>",
367                                     Subject    => "Status: $status{subject}",
368                                     "Reply-To" => "$gBug#$ref <$ref\@$gEmailDomain>",
369                                    ],
370                                    <<END,);
371 $status_message
372 thanks
373
374
375 END
376      }
377      my $message_number=0;
378      my %seen_message_ids;
379      for my $record (@records) {
380           next if $record->{type} !~ /^(?:recips|incoming-recv)$/;
381           my $wanted_type = $mbox_maint?'recips':'incoming-recv';
382           # we want to include control messages anyway
383           my $record_wanted_anyway = 0;
384           my ($msg_id) = $record->{text} =~ /^Message-Id:\s+<(.+)>/im;
385           next if exists $seen_message_ids{$msg_id};
386           next if $msg_id =~/handler\..+\.ack(?:info|done)?\@/;
387           $record_wanted_anyway = 1 if $record->{text} =~ /^Received: \(at control\)/;
388           next if not $boring and not $record->{type} eq $wanted_type and not $record_wanted_anyway and @records > 1;
389           $seen_message_ids{$msg_id} = 1;
390           my @lines = split( "\n", $record->{text}, -1 );
391           if ( $lines[ 1 ] =~ m/^From / ) {
392                my $tmp = $lines[ 0 ];
393                $lines[ 0 ] = $lines[ 1 ];
394                $lines[ 1 ] = $tmp;
395           }
396           if ( !( $lines[ 0 ] =~ m/^From / ) ) {
397                unshift @lines, "From unknown $date";
398           }
399           map { s/^(>*From )/>$1/ } @lines[ 1 .. $#lines ];
400           print join( "\n", @lines ) . "\n";
401      }
402      exit 0;
403 }
404
405 else {
406      my %seen_msg_ids;
407      for my $record (@records) {
408           $msg_num++;
409           if ($skip_next) {
410                $skip_next = 0;
411                next;
412           }
413           $skip_next = 1 if $record->{type} eq 'html' and not $boring;
414           push @log, handle_record($record,$ref,$msg_num,\%seen_msg_ids);
415      }
416 }
417
418 @log = reverse @log if $reverse;
419 $log = join("\n",@log);
420
421
422 my %maintainer = %{getmaintainers()};
423 my %pkgsrc = %{getpkgsrc()};
424
425 my $indexentry;
426 my $showseverity;
427
428 my $tpack;
429 my $tmain;
430
431 my $dtime = strftime "%a, %e %b %Y %T UTC", gmtime;
432 $tail_html = $gHTMLTail;
433 $tail_html =~ s/SUBSTITUTE_DTIME/$dtime/;
434
435 my %status = %{get_bug_status(bug=>$ref)};
436 unless (%status) {
437     print "Content-Type: text/html; charset=utf-8\n\n";
438     print fill_in_template(template=>'cgi/no_such_bug',
439                            variables => {modify_time => $dtime,
440                                          bug_num     => $ref,
441                                         },
442                           )
443     exit 0;
444 }
445
446 $|=1;
447
448 $tpack = lc $status{'package'};
449 my @tpacks = splitpackages($tpack);
450
451 if  ($status{severity} eq 'normal') {
452         $showseverity = '';
453 } elsif (isstrongseverity($status{severity})) {
454         $showseverity = "Severity: <em class=\"severity\">$status{severity}</em>;\n";
455 } else {
456         $showseverity = "Severity: $status{severity};\n";
457 }
458
459 if (@{$status{found_versions}} or @{$status{fixed_versions}}) {
460      $indexentry.= q(<div style="float:right"><a href=").
461           html_escape(version_url(package => $status{package},
462                                   found => $status{found_versions},
463                                   fixed => $status{fixed_versions},
464                                  )).
465           q("><img alt="version graph" src=").
466                html_escape(version_url(package => $status{package},
467                                        found => $status{found_versions},
468                                        fixed => $status{fixed_versions},
469                                        width => 2,
470                                        height => 2,
471                                       )).qq{"></a></div>};
472 }
473
474
475 $indexentry .= "<div class=\"msgreceived\">\n";
476 $indexentry .= htmlize_packagelinks($status{package}, 0) . ";\n";
477
478 foreach my $pkg (@tpacks) {
479     my $tmaint = defined($maintainer{$pkg}) ? $maintainer{$pkg} : '(unknown)';
480     my $tsrc = defined($pkgsrc{$pkg}) ? $pkgsrc{$pkg} : '(unknown)';
481
482     $indexentry .=
483             htmlize_maintlinks(sub { $_[0] == 1 ? "Maintainer for $pkg is\n"
484                                             : "Maintainers for $pkg are\n" },
485                            $tmaint);
486     $indexentry .= ";\nSource for $pkg is\n".
487             '<a href="'.html_escape(pkg_url(src=>$tsrc))."\">$tsrc</a>" if ($tsrc ne "(unknown)");
488     $indexentry .= ".\n";
489 }
490
491 $indexentry .= "<br>";
492 $indexentry .= htmlize_addresslinks("Reported by: ", \&submitterurl,
493                                 $status{originator}) . ";\n";
494 $indexentry .= sprintf "Date: %s.\n",
495                 (strftime "%a, %e %b %Y %T UTC", localtime($status{date}));
496
497 $indexentry .= "<br>Owned by: " . html_escape($status{owner}) . ".\n"
498               if length $status{owner};
499
500 $indexentry .= "</div>\n";
501
502 my @descstates;
503
504 $indexentry .= "<h3>$showseverity";
505 $indexentry .= sprintf "Tags: %s;\n", 
506                 html_escape(join(", ", sort(split(/\s+/, $status{tags}))))
507                         if length($status{tags});
508 $indexentry .= "<br>" if (length($showseverity) or length($status{tags}));
509
510 my @merged= split(/ /,$status{mergedwith});
511 if (@merged) {
512         my $descmerged = 'Merged with ';
513         my $mseparator = '';
514         for my $m (@merged) {
515                 $descmerged .= $mseparator."<a href=\"" . html_escape(bug_url($m)) . "\">#$m</a>";
516                 $mseparator= ",\n";
517         }
518         push @descstates, $descmerged;
519 }
520
521 if (@{$status{found_versions}}) {
522     my $foundtext = 'Found in ';
523     $foundtext .= (@{$status{found_versions}} == 1) ? 'version ' : 'versions ';
524     $foundtext .= join ', ', map html_escape($_), @{$status{found_versions}};
525     push @descstates, $foundtext;
526 }
527 if (@{$status{fixed_versions}}) {
528     my $fixedtext = '<strong>Fixed</strong> in ';
529     $fixedtext .= (@{$status{fixed_versions}} == 1) ? 'version ' : 'versions ';
530     $fixedtext .= join ', ', map html_escape($_), @{$status{fixed_versions}};
531     if (length($status{done})) {
532         $fixedtext .= ' by ' . html_escape(decode_rfc1522($status{done}));
533     }
534     push @descstates, $fixedtext;
535 }
536
537 if (@{$status{found_versions}} or @{$status{fixed_versions}}) {
538      push @descstates, '<a href="'.
539           html_escape(version_url($status{package},
540                                   $status{found_versions},
541                                   $status{fixed_versions},
542                                  )).qq{">Version Graph</a>};
543 }
544
545 if (length($status{done})) {
546     push @descstates, "<strong>Done:</strong> ".html_escape(decode_rfc1522($status{done}));
547 }
548
549 if (length($status{forwarded})) {
550     my $forward_link = html_escape($status{forwarded});
551     $forward_link =~ s,((ftp|http|https)://[\S~-]+?/?)((\&gt\;)?[)]?[']?[:.\,]?(\s|$)),<a href="$1">$1</a>$3,go;
552     push @descstates, "<strong>Forwarded</strong> to $forward_link";
553 }
554
555
556 my @blockedby= split(/ /, $status{blockedby});
557 if (@blockedby && $status{"pending"} ne 'fixed' && ! length($status{done})) {
558     for my $b (@blockedby) {
559         my %s = %{get_bug_status($b)};
560         next if $s{"pending"} eq 'fixed' || length $s{done};
561         push @descstates, "Fix blocked by <a href=\"" . html_escape(bug_url($b)) . "\">#$b</a>: ".html_escape($s{subject});
562     }
563 }
564
565 my @blocks= split(/ /, $status{blocks});
566 if (@blocks && $status{"pending"} ne 'fixed' && ! length($status{done})) {
567     for my $b (@blocks) {
568         my %s = %{get_bug_status($b)};
569         next if $s{"pending"} eq 'fixed' || length $s{done};
570         push @descstates, "Blocking fix for <a href=\"" . html_escape(bug_url($b)) . "\">#$b</a>: ".html_escape($s{subject});
571     }
572 }
573
574 if ($buglog !~ m#^\Q$gSpoolDir/db#) {
575     push @descstates, "Bug is archived. No further changes may be made";
576 }
577
578 $indexentry .= join(";\n<br>", @descstates) . ".\n" if @descstates;
579 $indexentry .= "</h3>\n";
580
581 my $descriptivehead = $indexentry;
582
583 print "Content-Type: text/html; charset=utf-8\n";
584
585 my @stat = stat $buglog;
586 if (@stat) {
587      my $mtime = strftime '%a, %d %b %Y %T GMT', gmtime($stat[9]);
588      print "Last-Modified: $mtime\n";
589 }
590
591 print "\n";
592
593 my $title = html_escape($status{subject});
594
595 my $dummy2 = $gWebHostBugDir;
596
597 print "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">\n";
598 print <<END;
599 <HTML><HEAD>
600 <TITLE>$short - $title - $gProject $gBug report logs</TITLE>
601 <meta http-equiv="Content-Type" content="text/html;charset=utf-8">
602 <link rel="stylesheet" href="$gWebHostBugDir/css/bugs.css" type="text/css">
603 <script type="text/javascript">
604 <!--
605 function toggle_infmessages()
606 {
607         allDivs=document.getElementsByTagName("div");
608         for (var i = 0 ; i < allDivs.length ; i++ )
609         {
610                 if (allDivs[i].className == "infmessage")
611                 {
612                         allDivs[i].style.display=(allDivs[i].style.display == 'none' | allDivs[i].style.display == '') ? 'block' : 'none';
613                 }
614         }
615 }
616 -->
617 </script>
618 </HEAD>
619 <BODY>
620 END
621 print "<H1>" . "$gProject $gBug report logs - <A HREF=\"mailto:$ref\@$gEmailDomain\">$short</A>" .
622       "<BR>" . $title . "</H1>\n";
623 print "$descriptivehead\n";
624
625 if (looks_like_number($msg)) {
626      printf qq(<p><a href="%s">Full log</a></p>),html_escape(bug_url($ref));
627 }
628 else {
629      print qq(<p><a href="mailto:$ref\@$gEmailDomain">Reply</a> ),
630           qq(or <a href="mailto:$ref-subscribe\@$gEmailDomain">subscribe</a> ),
631                qq(to this bug.</p>\n);
632      print qq(<p><a href="javascript:toggle_infmessages();">Toggle useless messages</a></p>);
633      printf qq(<div class="msgreceived"><p>View this report as an <a href="%s">mbox folder</a>, ).
634           qq(<a href="%s">status mbox</a>, <a href="%s">maintainer mbox</a></p></div>\n),
635                html_escape(bug_url($ref, mbox=>'yes')),
636                     html_escape(bug_url($ref, mbox=>'yes',mboxstatus=>'yes')),
637                          html_escape(bug_url($ref, mbox=>'yes',mboxmaint=>'yes'));
638 }
639 print "$log";
640 print "<HR>";
641 print "<p class=\"msgreceived\">Send a report that <a href=\"/cgi-bin/bugspam.cgi?bug=$ref\">this bug log contains spam</a>.</p>\n<HR>\n";
642 print $tail_html;
643
644 print "</BODY></HTML>\n";
645
646 exit 0;