r6731 - /man-cgi/man.cgi
Author: jfs
Date: Sat Jun 6 11:09:20 2009
New Revision: 6731
URL: http://svn.debian.org/wsvn/?sc=1&rev=6731
Log:
Modify regexp for manpages and make it easier to debug behaviour
Modified:
man-cgi/man.cgi
Modified: man-cgi/man.cgi
URL: http://svn.debian.org/wsvn/man-cgi/man.cgi?rev=6731&op=diff
==============================================================================
--- man-cgi/man.cgi (original)
+++ man-cgi/man.cgi Sat Jun 6 11:09:20 2009
@@ -47,6 +47,9 @@
$www{'home'} = 'http://manpages.debian.net';
$www{'head'} = qq[<IMG height=61 width=60 SRC="http://www.debian.org/logos/openlogo-nd-50.png" Alt="[Debian Logo]"><img src="http://www.debian.org/Pics/debian.png" width="179" height="61" alt="Debian project">] .
"";
+
+# Set this to 1 (or above) to debug the CGI script
+$debug = 0;
#$command{'man'} = 'man'; # 8Bit clean man
#$command{'man'} = '/home/wosch/bin/cgi-man'; # 8Bit clean man
@@ -287,9 +290,9 @@
$format = 'html' if $format !~ /^(ps|pdf|ascii|latin1|dvi|troff)$/;
local($fform) = &dec($form);
- if ($fform =~ m%^([a-zA-Z_\-:\+\.\-]+)$%) {
+ if ($fform =~ m%^([\w\_\-\:\+\.]+)$%) {
return &man($1, '');
- } elsif ($fform =~ m%^([a-zA-Z_\-:\+\.\-]+)\(([0-9a-zA-Z]+)\)$%) {
+ } elsif ($fform =~ m%^([\w\_\-\:\+\.]+)\(([0-9a-zA-Z]+)\)$%) {
return &man($1, $2);
}
@@ -553,14 +556,14 @@
return;
}
- if ( $name =~ /^([\-\_\+\.\w]+)/ ) {
+ if ( $name =~ /^([\w\_\-\:\+\.]+)/ ) {
$name = $1
} else {
print "Sorry, name `$name' is not valid\n";
return
}
- if ($section !~ /^[0-9ln]\w*$/ && $section ne '') {
+ if ($section !~ /^[0-9lnpm]\w*$/ && $section ne '') {
print "Sorry, section `$section' is not valid\n";
return;
}
@@ -603,7 +606,7 @@
$manPath{$manpath} = join(':', @locale_manpath);
}
- # print "X $manpath - $locale - $manPath{$manpath} x\n"; # DEBUG
+ print "X $manpath - $locale - $manPath{$manpath} x\n" if $debug;
if ($manpath) {
if ($manPath{$manpath}) {
unshift(@manargs, ('-M', $manPath{$manpath}));
@@ -622,14 +625,14 @@
push(@manargs, '-t');
}
- #print "X $command{'man'} @manargs -- $section $name x\n"; # DEBUG
+ print "X $command{'man'} @manargs -- $section $name x\n" if $debug;
#die "Section $section is tainted\n" if is_tainted($section);
- # printenv(); #DEBUG
- #print " X Calling $command{'man'} ".join(" ",@manargs)." for $name ($section)\n"; #DEBUG
+ printenv() if $debug > 1;
+ print "X Calling $command{'man'} ".join(" ",@manargs)." for $name ($section)\n" if $debug;
&proc(*MAN, $command{'man'}, @manargs, "--", $section, $name) ||
&mydie ("$0: open of $command{'man'} command failed: $!\n");
if (eof(MAN)) {
- # print "X $command{'man'} @manargs -- $section $name x\n";
+ print "X $command{'man'} @manargs -- $section $name x\n" if $debug;
print "Sorry, no data found for `$html_name" .
($html_section ? "($html_section)": '') . "'.\n";
if ( $locale) {
Reply to: