From c68e61f9d1007b5c4b99a5096ee8615c071a5bae Mon Sep 17 00:00:00 2001 From: Wolfram Schneider Date: Mon, 16 Jul 2007 17:36:53 +0000 Subject: [PATCH] HTML output conforms to XHTML 1.0 Transitional --- en/cgi/man.cgi | 235 +++++++++++++++++++++++++------------------------ 1 file changed, 120 insertions(+), 115 deletions(-) diff --git a/en/cgi/man.cgi b/en/cgi/man.cgi index 95b20f9e34..33a247cc07 100755 --- a/en/cgi/man.cgi +++ b/en/cgi/man.cgi @@ -33,7 +33,7 @@ # BSDI Id: bsdi-man,v 1.2 1995/01/11 02:30:01 polk Exp # Dual CGI/Plexus mode and new interface by sanders@bsdi.com 9/22/1995 # -# $Id: man.cgi,v 1.176 2007-07-16 17:33:41 wosch Exp $ +# $Id: man.cgi,v 1.177 2007-07-16 17:36:53 wosch Exp $ ############################################################################ # !!! man.cgi is stale perl4 code !!! @@ -585,7 +585,7 @@ sub apropos { &http_header("text/html"); print &html_header("Apropos $title"); - print "

$www{'head'}

\n\n"; + print "

", $www{'head'}, "

\n\n"; &formquery; local($mpath) = $manPath{$manpath}; @@ -593,7 +593,7 @@ sub apropos { open(APROPOS, "env MANPATH=$mpath $command{'man'} -k . |") || do { warn "$0: Cannot open whatis database for `$mpath'\n"; print "Cannot open whatis database for `$mpath'\n"; - print "\n\n\n"; + print "\n\n\n"; return; }; @@ -611,10 +611,10 @@ sub apropos { $key =~ s/\s+$//; $key =~ s/.*\s+//; ($names, $msg) = m/^(.*\))\s+-\s+(.*)/; - print "
", - &encode_data("$names"), "\n
", + print "
", + &encode_data("$names"), "\n
", &encode_data($msg), "\n"; } close(APROPOS); @@ -624,7 +624,7 @@ sub apropos { print qq{You may look for other } . qq{FreeBSD Search Services.\n}; } - print "\n\n\n"; + print "\n\n\n"; } sub man { @@ -653,9 +653,9 @@ sub man { if ($format eq "html") { &http_header("text/html"); print &html_header("$title"); - print "

$www{'head'}

\n\n"; + print "

", $www{'head'}, "

\n\n"; &formquery; - print "
\n";
+	print "
\n";
     } else {
 	#$format =~ /^(ps|ascii|latin1|dvi|troff)$/')
 	$ENV{'NROFF_FORMAT'} = $format;
@@ -806,40 +806,43 @@ sub man {
 
 	$_ = &encode_data($_);
 	if($enable_include_links &&
-	   m,()?\#include()?\s+()?\<\;(.*\.h)\>\;()?,) {
+	   m,()?\#include()?\s+()?\<\;(.*\.h)\>\;()?,) {
 	    $match = $4; ($regexp = $match) =~ s/\./\\\./;
-	    s,$regexp,\$match\,;
+	    s,$regexp,\$match\,;
         }
 	/^\s/ && 			# skip headers
 	    s,((<[IB]>)?[\w\_\.\-]+\s*()?\s*\(([1-9ln][a-zA-Z]*)\)),&mlnk($1),oige;
 
 	# detect E-Mail Addreses in manpages
 	if ($enable_mailto_links && /\@/) {
-	    s/([a-z0-9_\-\.]+\@[a-z0-9\-\.]+\.[a-z]+)/$1<\/A>/gi;
+	    s/([a-z0-9_\-\.]+\@[a-z0-9\-\.]+\.[a-z]+)/$1<\/A>/gi;
 	}
 
 	# detect URLs in manpages
 	if (m%tp://%) {
-	    s,((ftp|http)://[^\s<>\)]+),$1,gi;
+	    s,((ftp|http)://[^\s<>\)]+),$1,gi;
 	}
 
-	if (s%^(.*?)+$% ($str = $1) =~ s,(|),,g; "$str" %ge ) {
+	if (s%^(.*?)+\n?$% ($str = $1) =~ s,(|),,g; $str%ge ) {
 	    $i = $_; $j = &encode_url($i);
-	    $_ = qq{$i};
+	    $j =~ s/\+/_/g;
+	    $_ = qq{$i};
 	    push(@sect, $i);
         }
 	print;
     }
     close(MAN);
-    print qq{
\n\n
\n}; + print qq{
\n\n
\n}; for ($i = 0; $i <= $#sect; $i++) { - print qq{
$sect[$i]} . ($i < $#sect ? " |\n" : "\n"); } - print "\n"; - print "\n"; + print "\n"; + print "\n"; # Sleep 0.35 seconds to avoid DoS attacs select undef, undef, undef, 0.35; @@ -876,8 +879,8 @@ sub mlnk { $link = &encode_url($link); $section = &encode_url($section); local($manpath) = &encode_url($manpath); - return qq{$matched}; + return qq{$matched}; } sub proc { @@ -929,7 +932,7 @@ sub splitquery { grep((s/%([\da-f]{1,2})/pack(C,hex($1))/eig, 1), split(/\+/, $query)); } -# encode unknown data for use in a URL +# encode unknown data for use in a URL sub encode_url { local($_) = @_; # rfc1738 says that ";"|"/"|"?"|":"|"@"|"&"|"=" may be reserved. @@ -967,13 +970,13 @@ sub encode_data { s/\/\>\;/g; - s,((_\010[^_])+),($str = $1) =~ s/.\010//g; "$str";,ge; - s,((.\010.)+),($str = $1) =~ s/.\010//g; "$str";,ge; + s,((_\010[^_])+),($str = $1) =~ s/.\010//g; "$str";,ge; + s,((.\010.)+),($str = $1) =~ s/.\010//g; "$str";,ge; - #s,((_\010.)+),($str = $1) =~ s/.\010//g; "$str";,ge; + #s,((_\010.)+),($str = $1) =~ s/.\010//g; "$str";,ge; #s,(.\010)+,$1,g; - #if (!s,((.\010.)+\s+(.\010.)+),($str = $1) =~ s/.\010//g; "$str";,ge) { - # s,(([^_]\010.)+),($str = $1) =~ s/[^_]\010//g; "$str";,ge; + #if (!s,((.\010.)+\s+(.\010.)+),($str = $1) =~ s/.\010//g; "$str";,ge) { + # s,(([^_]\010.)+),($str = $1) =~ s/[^_]\010//g; "$str";,ge; # s,(([_]\010.)+),($str = $1) =~ s/[_]\010//g; "$str";,ge; #} # Escape binary data except for ^H which we process below @@ -996,112 +999,112 @@ sub encode_data { sub indexpage { &http_header("text/html"); print &html_header("$www{'title'}: Index Page") . - "

$www{'head'}

\n\n" . &intro; + "

", $www{'head'}, "

\n\n" . &intro; &formquery; local($m) = ($manpath ? $manpath : $manPathDefault); $m = &encode_url($m); - print "Section Indexes:\n"; + print "Section Indexes:\n"; foreach ('1', '2', '3', '4', '5', '6', '7', '8', '9', 'n') { print qq{¤ } if $_ ne '1'; - print qq{
$_\n}; + print qq{$_\n}; } - print "
Explanations of Man Sections:\n"; + print "
Explanations of Man Sections:\n"; foreach ('1', '2', '3', '4', '5', '6', '7', '8', '9') { print qq{¤ } if $_ ne '1'; - print qq{intro($_)\n}; + print qq{intro($_)\n}; } if (0) { - print "
\nQuick Reference Categories:\n"; + print "
\nQuick Reference Categories:\n"; foreach ('database', 'disk', 'driver', 'ethernet', 'mail', 'net', 'nfs', 'nis', 'protocol', 'ppp', 'roff', 'string', 'scsi', 'statistic', 'tcl', 'tcp', 'time') { - print qq{¤ $_\n}; + print qq{¤ $_\n}; } } print < -URL: $www{'home'}$BASE
+
+URL: $www{'home'}$BASE
ETX - print "
\n"; - print "\n\n"; + print "
\n"; + print "\n\n"; 0; } sub formquery { local($astring, $bstring); if (!$apropos) { - $astring = " CHECKED"; + $astring = q{ checked="checked"}; } else { - $bstring = " CHECKED"; + $bstring = q{ checked="checked"}; } print < -Man Page or Keyword Search: - - - -
- Man - + + +
+ Man +\n\n Apropos Keyword Search (all sections) - +
+ Apropos Keyword Search (all sections) + Output format - + -home | -help -
+home | +help +
ETX 0; } sub copyright { - $id = '$Id: man.cgi,v 1.176 2007-07-16 17:33:41 wosch Exp $'; + $id = '$Id: man.cgi,v 1.177 2007-07-16 17:36:53 wosch Exp $'; return qq{\ -
-Copyright (c) 1996-2007 Wolfram Schneider
+
+Copyright (c) 1996-2007 Wolfram Schneider
 Copyright (c) 1993-1995 Berkeley Software Design, Inc.
 
 This data is part of a licensed program from BERKELEY SOFTWARE
@@ -1109,12 +1112,12 @@ DESIGN, INC.  Portions are copyrighted by BSDI, The Regents of
 the University of California, Massachusetts Institute of
 Technology, Free Software Foundation, FreeBSD Inc., and others.
 
-
\n +
\n This script has the revsion: $id -

+

Copyright (©) for man pages by OS vendors. -

+

2.11 BSD, HP, FreeBSD, @@ -1139,7 +1142,7 @@ sub faq { foreach (sort keys %manPath) { $url = &encode_url($_); push(@list, - qq{

  • [download]} . + qq{
  • [download]} . qq{ "$_" -> $BASE?manpath=$url}); } @@ -1149,10 +1152,10 @@ sub faq { &encode_url($_) . "\n") if $manPathAliases{$_}; } - local $id = '$Id: man.cgi,v 1.176 2007-07-16 17:33:41 wosch Exp $'; + local $id = '$Id: man.cgi,v 1.177 2007-07-16 17:36:53 wosch Exp $'; return qq{\ -
    -Copyright (c) 1996-2007 Wolfram Schneider
    +
    +Copyright (c) 1996-2007 Wolfram Schneider
     Copyright (c) 1993-1995 Berkeley Software Design, Inc.
     
     This data is part of a licensed program from BERKELEY SOFTWARE
    @@ -1160,12 +1163,12 @@ DESIGN, INC.  Portions are copyrighted by BSDI, The Regents of
     the University of California, Massachusetts Institute of
     Technology, Free Software Foundation, FreeBSD Inc., and others.
     
    -
    \n +
    \n This script has the revsion: $id -

    +

    Copyright (c) for man pages by OS vendors. -

    +

    2.11 BSD, HP, FreeBSD, @@ -1182,7 +1185,7 @@ Copyright (c) for man pages by OS vendors. X11R6

    FAQ

    -
      +
      • Get the source of the man.cgi script
      • Troff macros works only if defined in FreeBSD/groff. OS specific macros like `appeared in NetBSD version 1.2' are not supported. @@ -1196,16 +1199,16 @@ Unix family tree, BSD part. FreeBSD Ports Changes script.
      • Copyright (c) and download for man pages by OS vendors -
      +

    Releases

    Releases and Releases Aliases are information how to make a link to this script to the right OS version. -

    +

    You may download the manpages as gzip'd tar archive for private use. A tarball is usually 5MB big. -

    +

      @list
    @@ -1222,59 +1225,61 @@ lifetime, eg. 'openbsd' points always to the latest OpenBSD release. sub intro { return qq{\ -

    -Man Page Lookup searches for man pages name and section as -given in the selection menu and the query dialog. Apropos -Keyword Search searches the database for the string given in +

    +Man Page Lookup searches for man pages name and section as +given in the selection menu and the query dialog. Apropos +Keyword Search searches the database for the string given in the query dialog. There are also several hypertext links provided -as short-cuts to various queries: Section Indexes is apropos -listings of all man pages by section. Explanations of Man -Sections contains pointers to the intro pages for various man +as short-cuts to various queries: Section Indexes is apropos +listings of all man pages by section. Explanations of Man +Sections contains pointers to the intro pages for various man sections. -

    +

    }; } sub copyright_output { &http_header("text/html"); print &html_header("HTML hypertext FreeBSD man page interface") . - "

    $www{'head'}

    \n" . ©right . qq{\ -
    + "

    ", $www{'head'}, "

    \n" . ©right . qq{\ +
    -home - - +home + + }; } sub faq_output { &http_header("text/html"); print &html_header("HTML hypertext FreeBSD man page interface") . - "

    $www{'head'}

    \n" . &faq . qq{\ -
    + "

    ", $www{'head'}, "

    \n" . &faq . qq{\ +
    -home - - +home + + }; } sub html_header { - return qq{ - -$_[0] - - - + return qq{ + + +$_[0] + + - -\n\n}; + + +}; } sub secure_env { @@ -1304,10 +1309,10 @@ sub mydie { print $message; print qq{ -

    -home - - +

    +home + + }; exit(0);