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