X-Git-Url: https://git.distorted.org.uk/~mdw/sw-tools/blobdiff_plain/961ce1c2fa0e71e5ffc0c16a1d4fa58802a36a1c..9796a7877cd1e7f6908c678e71b8fea6045ba0e7:/perl/SWInfo.pm diff --git a/perl/SWInfo.pm b/perl/SWInfo.pm index 04898df..4ff6e2c 100644 --- a/perl/SWInfo.pm +++ b/perl/SWInfo.pm @@ -1,6 +1,6 @@ # -*-perl-*- # -# $Id: SWInfo.pm,v 1.1 1999/07/30 18:46:37 mdw Exp $ +# $Id: SWInfo.pm,v 1.5 2004/04/08 01:52:19 mdw Exp $ # # Read and output GNU Info files # @@ -25,13 +25,6 @@ # along with sw-tools; if not, write to the Free Software Foundation, # Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -#----- Revision history ----------------------------------------------------- -# -# $Log: SWInfo.pm,v $ -# Revision 1.1 1999/07/30 18:46:37 mdw -# New CGI script for browsing installed software and documentation. -# - #----- Package preamble ----------------------------------------------------- package SWInfo; @@ -74,11 +67,10 @@ sub subst($$$) { # --- Transform it into something that won't get mangled --- - $node =~ s/[+&=%]|[^ -~]/sprintf("%%%02x", ord($&))/eg; - $node =~ tr/ /+/; + $node = SWCGI::sanitize($node); ($dir = $i->{dir}) =~ s:$C{prefix}/info/?::; - $dir = "&dir=$dir" if $dir; + $dir = "&dir=" . SWCGI::sanitize($dir) if $dir; return "$oref$tail"; } @@ -106,8 +98,8 @@ sub info { # --- Now translate the node into HTML, first line first --- $n =~ s/\&/&/; - $n =~ s/\/>/; + $n =~ s/\/>>/; $n =~ s/\A( [^\n]* Next:\ *) ([^,\n]*) / $1 . subst($2, $file, $i) /eix; $n =~ s/\A( [^\n]* Prev:\ *) ([^,\n]*) / $1 . subst($2, $file, $i) /eix; $n =~ s/\A( [^\n]* Up:\ *) ([^,\n]*) / $1 . subst($2, $file, $i) /eix; @@ -141,9 +133,29 @@ sub info { } $out .= $n; - $out =~ s!(http|ftp)://[^]&)\s]*[^]&).,\s\'\"]!$&!g; - $out =~ s![^\s()&;{}.,\`\"][^\s()&;{}\`\"]*\@[^\s()&;{}\'\"]*[^\s()&;{}.,\'\"]!$&!g; - $out =~ s!([-_.\w]+)\((\d+\w*)\)!SWMan::subst("$1($2)", $1, $2)!eg; + # --- Spot URLs (except `mailto') --- + + $out =~ s! \b (http s? | ftp | file | news) : + [^]<>)\s]* [^]<>).,\s\'] + !urlsubst($&, $&)!egx; + + # --- Spot email addresses (including `mailto' URLs) --- + + $out =~ s! (?:\bmailto:)? + ([^\s()<>&;:{}.,\`\'\"] [^\s()<>&;:{}\`\'\"]* + \@ + [^\s()<>&;:{}\'\"]* [^\s()<>&;:{}.,\'\"]) + !$&!gx; + + # --- Spot manpage references --- + + $out =~ s! ([-_.\w]+) \( (\d+\w*) \) + !SWMan::subst("$1($2)", $1, $2)!egx; + + # --- Fix up the HTML --- + + $out =~ s/\<\\>/>/g; header("Info: ($file)$node"); print("
\n$out
\n");