]> git.donarmstrong.com Git - debbugs.git/blob - cgi/bugs-fetch2.pl.in
f9e1e33e04da93fe570b51566f8edd203b0e3a9f
[debbugs.git] / cgi / bugs-fetch2.pl.in
1 #!/usr/bin/perl
2
3 require '/etc/debbugs/config';
4 require './cgi-lib.pl';
5
6 %map= ($gMirrors);
7
8 ReadParse() or CgiDie("need form data");
9
10 if ($in{'type'} eq 'ref') {
11     $_= $in{'ref'};
12     s/^\s+//; s/^\#//; s/^\s+//; s/^0*//; s/\s+$//;
13
14     if (m/\D/ || !m/\d/) {
15         print <<END;
16 Content-Type: text/html
17
18 <html><head><title>Bug number not numeric</title>
19 </head><body>
20 <h1>Invalid input to specific bug fetch form</h1>
21
22 You must type a number, being the bug reference number.
23 There should be no nondigits in your entry.
24 </html>
25 END
26         exit(0);
27     }
28     $suburl= $_;
29     $suburl =~ s,^..,$&/$&,;
30     $suburl.= '.html';
31 } elsif ($in{'type'} eq 'package') {
32     $_= $in{'package'};
33     s/^\s+//; s/\s+$//; y/A-Z/a-z/;
34     if (m/^[^0-9a-z]/ || m/[^-+.0-9a-z]/) {
35         print <<END;
36 Content-Type: text/html
37
38 <html><head><title>Package name contains invalid characters</title>
39 </head><body>
40 <h1>Invalid input to package buglist fetch form</h1>
41
42 You must type a package name.  Package names start with a letter
43 or digit and contain only letters, digits and the characters
44 - + . (hyphen, plus, full stop).
45 </html>
46 END
47         exit(0);
48     }
49     $suburl= "pa/l$_.html";
50 } else {
51     print <<END;
52 Content-Type: text/plain
53
54 Please use the real DBC_WHO form. (invalid type value)
55 END
56     exit(0);
57 }
58
59 $base= $ENV{'HTTP_REFERER'};
60 if ($base =~ s:/Bugs/.*$::) {
61     for $y (keys %map) {
62         $base= $map{$y} if $base eq $y;
63     }
64 } else {
65     $base= $in{'base'};
66 }
67
68 $newurl= "$base/Bugs/db/$suburl";
69 print <<END;
70 Status: 301 Redirect
71 Location: $newurl
72
73 The bug report data you are looking for ($suburl)
74 is available <A href="$newurl">here</A>.
75
76 (If this link does not work then the bug or package does not exist in
77 the tracking system any more, or does not yet, or never did.)
78 END
79
80 exit(0);