X-Git-Url: https://git.distorted.org.uk/~mdw/sw-tools/blobdiff_plain/961ce1c2fa0e71e5ffc0c16a1d4fa58802a36a1c..9796a7877cd1e7f6908c678e71b8fea6045ba0e7:/perl/SWCGI.pm diff --git a/perl/SWCGI.pm b/perl/SWCGI.pm index 2e28455..513fb54 100644 --- a/perl/SWCGI.pm +++ b/perl/SWCGI.pm @@ -1,6 +1,6 @@ # -*-perl-*- # -# $Id: SWCGI.pm,v 1.1 1999/07/30 18:46:37 mdw Exp $ +# $Id: SWCGI.pm,v 1.3 2004/04/08 01:52:19 mdw Exp $ # # Miscellaneous CGI support functions # @@ -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: SWCGI.pm,v $ -# Revision 1.1 1999/07/30 18:46:37 mdw -# New CGI script for browsing installed software and documentation. -# - #----- Package header ------------------------------------------------------- package SWCGI; @@ -41,7 +34,7 @@ use SWConfig; @ISA = qw(Exporter); @EXPORT = qw(barf %Q $ref); -@EXPORT_OK = qw(read); +@EXPORT_OK = qw(read sanitize); %EXPORT_TAGS = (layout => [qw(header footer)], debug => [qw(dumphash)]); @@ -130,6 +123,16 @@ sub dumphash(\%) { print "\n"; } +#----- Sanitizing links ----------------------------------------------------- + +sub sanitize($) { + my ($l) = @_; + $l =~ s/[+&%=]/"%" . sprintf("%02x", ord($&))/eg; + $l =~ tr/ /+/; + $l =~ s/[^!-~]/"%" . sprintf("%02x", ord($&))/eg; + return $l; +} + #----- Argument reading ----------------------------------------------------- %Q = ();