From 720e78a4f8351eedac26b196aa9f3922fd5bd0ee Mon Sep 17 00:00:00 2001 From: Juerd Waalboer Date: Wed, 2 May 2001 11:28:05 +0000 Subject: [PATCH] v2.22 release --- .htaccess | 2 ++ INSTALL | 9 +++++++++ plp.cgi | 28 ++++++++++++++++++++++------ plpfunc.pm | 21 ++++++++++++--------- 4 files changed, 45 insertions(+), 15 deletions(-) create mode 100644 .htaccess create mode 100644 INSTALL diff --git a/.htaccess b/.htaccess new file mode 100644 index 0000000..1d3d6e5 --- /dev/null +++ b/.htaccess @@ -0,0 +1,2 @@ +RemoveHandler .cgi +ForceType text/plain \ No newline at end of file diff --git a/INSTALL b/INSTALL new file mode 100644 index 0000000..b34f4bf --- /dev/null +++ b/INSTALL @@ -0,0 +1,9 @@ +# httpd.conf += + +AddHandler plp-document .plp +Action plp-document /cgi-bin/plp.cgi + +# /cgi-bin/ can be any globaly existing directory (I use /COMMON/ because +# cgi-bin's are local (mod_vhost_alias)) + +# read http://plp.juerd.nl/ \ No newline at end of file diff --git a/plp.cgi b/plp.cgi index 3bf77f9..4c6e41e 100755 --- a/plp.cgi +++ b/plp.cgi @@ -2,9 +2,12 @@ use strict; use vars qw($VERSION %INTERNAL %get %post %fields %header %cookie %BLOCK $DEBUG $output); -$VERSION = '2.21'; +$VERSION = '2.22'; $DEBUG = 1; +# We put most everything in %INTERNAL, just so the user won't screw it. +# We could also have used packages, but let's keep it simple. + $INTERNAL{file} = $ENV{PATH_TRANSLATED}; unless (-e $INTERNAL{file}){ $ENV{REDIRECT_STATUS} = '404'; @@ -26,8 +29,8 @@ use plp; $INTERNAL{qq} = ""; #^P $INTERNAL{q} = ""; #^Q -$header{'content-type'} = 'text/html'; -$header{status} = '200 OK'; +$header{'Content-Type'} = 'text/html'; +$header{Status} = '200 OK'; $INTERNAL{code} = ReadFile($INTERNAL{file}); @@ -49,6 +52,8 @@ $INTERNAL{code} =~ s(\\\\\r?\n)()g; $INTERNAL{code} =~ s(<\[([^>]*?):(.*?)\]>)($BLOCK{"${1}-1"}$2$BLOCK{"${1}-2"})g; $INTERNAL{code} =~ s(<\[(?!/)(.*?)\]>)($BLOCK{"${1}-1"})g; $INTERNAL{code} =~ s(<\[/(.*?)\]>)($BLOCK{"${1}-2"})g; + + $INTERNAL{code} =~ s(<{[ \08\09]*)($INTERNAL{q};print qq$INTERNAL{qq})g; $INTERNAL{code} =~ s([ \08\09]*}>)($INTERNAL{qq};print q$INTERNAL{q})g; $INTERNAL{code} = "print q$INTERNAL{q}$INTERNAL{code}$INTERNAL{q};"; @@ -68,10 +73,21 @@ while ($INTERNAL{code} =~ s/<_(.*?)_>//s){ } } -for (keys %header){ - print "$_: $header{$_}\n"; +print "\n\n" if $DEBUG == 2; + +{ + my %HEADER; + for (sort keys %header){ # Sort, so lowercase and underscores come first) + my $copy = $_; + tr/_/-/; + s/\b(\w)(\w*)/\U$1\E\L$2\E/g; + $HEADER{$_} = $header{$copy}; + } + for (keys %HEADER){ + print "$_: $HEADER{$_}\n"; + } + print "\n"; } -print "\n"; { no strict; diff --git a/plpfunc.pm b/plpfunc.pm index 49bb63c..a113c76 100644 --- a/plpfunc.pm +++ b/plpfunc.pm @@ -31,7 +31,7 @@ sub Entity(@){ s//>/g; s/\n/
\n/g; - s/\t/ /eg; + s/\t/        /g; s/ /  /g; }; if ($@){ return defined wantarray ? @_ : undef } @@ -108,6 +108,7 @@ sub Counter($){ } sub AutoURL($){ + # This sub assumes your string does not match /(["<>])\cC\1/ my $ref; if (defined wantarray){ $ref = \(my $copy = $_[0]); @@ -115,19 +116,21 @@ sub AutoURL($){ $ref = \$_[0]; } eval { - my ($p, $b, $c); - $$ref =~ s/"/"\cC"/g; - $$ref =~ s/>/>\cC>/g; + $$ref =~ s/"/"\cC"/g; # Single characters are easier to match :) + $$ref =~ s/>/>\cC>/g; # so we can just use a character class [] $$ref =~ s/</<\cC< \r\t\n]*)}{ - local $_ = $1, $p = $2, ((($b) = /([\.,!\?\(\)\[\]]+$)/) ? s/// : - undef), s/&(?!\x23?\w+;)/&/g, s/\"/"/g, $c = - ($p eq 'www.' || $p eq 'WWW.' ? "http://$_" : $_), - qq{$_$b} + local $_ = $1; + my $scheme = $2; + s/// if (my $trailing) = /([\.,!\?\(\)\[\]]+$)/; + s/&(?!\x23?\w+;)/&/g; + s/\"/"/g; + my $href = ($scheme =~ /www\./i ? "http://$_" : $_); + qq{$_$trailing}; }eg; - $$ref =~ s/"\cC"/"/g; $$ref =~ s/>\cC>/>/g; $$ref =~ s/<\cC