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