From 14aff3ebf5dee188627d70d80d517870c9862939 Mon Sep 17 00:00:00 2001 From: Martin Mares Date: Fri, 6 Sep 2002 17:00:13 +0000 Subject: [PATCH] Added first two functions of the Poor Man's CGI module. --- lib/perl/CGI.pm | 39 +++++++++++++++++++++++++++++++++++++++ lib/perl/Makefile | 2 +- 2 files changed, 40 insertions(+), 1 deletion(-) create mode 100644 lib/perl/CGI.pm diff --git a/lib/perl/CGI.pm b/lib/perl/CGI.pm new file mode 100644 index 00000000..255859e5 --- /dev/null +++ b/lib/perl/CGI.pm @@ -0,0 +1,39 @@ +# Poor Man's CGI Module for Perl +# +# (c) 2002 Martin Mares +# +# This software may be freely distributed and used according to the terms +# of the GNU Lesser General Public License. + +package Sherlock::CGI; + +use strict; +use warnings; + +BEGIN { + # The somewhat hairy Perl export mechanism + use Exporter(); + our ($VERSION, @ISA, @EXPORT, @EXPORT_OK, %EXPORT_TAGS); + $VERSION = 1.0; + @ISA = qw(Exporter); + @EXPORT = qw(&html_escape &url_escape); + @EXPORT_OK = qw(); + %EXPORT_TAGS = (); +} + +sub url_escape($) { + my $x = shift @_; + $x =~ s/([^-\$_.+!*'(),0-9A-Za-z\x80-\xff])/"%".unpack('H2',$1)/ge; + return $x; +} + +sub html_escape($) { + my $x = shift @_; + $x =~ s/&/&/g; + $x =~ s//>/g; + $x =~ s/"/"/g; + return $x; +} + +1; # OK diff --git a/lib/perl/Makefile b/lib/perl/Makefile index f0bddeeb..3b9e9257 100644 --- a/lib/perl/Makefile +++ b/lib/perl/Makefile @@ -1,4 +1,4 @@ # Perl modules DIRS+=lib/perl -PROGS+=$(addprefix obj/lib/perl/,Config.pm Query.pm) +PROGS+=$(addprefix obj/lib/perl/,Config.pm Query.pm CGI.pm) -- 2.39.2