# -*-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
#
# 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;
@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)]);
print "</table>\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 = ();