#!/usr/bin/perl use strict; $| = 1; my @pairs = (); my @result = (); my ($buffer,$pair,$name,$value,$temp,$destination); my %FORM = (); # to prevent runaways, call it quits after 60 seconds. $SIG{'ALRM'} =\&alarm_handle; alarm(60); if ($ENV{'REQUEST_METHOD'} eq "POST") { read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'}); } else { $buffer = $ENV{'QUERY_STRING'}; } @pairs = split(/&/, $buffer); foreach $pair (@pairs) { ($name, $value) = split(/=/, $pair); $value =~ tr/+/ /; $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; $FORM{$name} = $value; } $destination = $FORM{'URL'}; $destination = "http://".$destination unless ($destination =~ m|http://|); # remove all non URL allowable stuff. chomp($destination); $destination =~ s/ \-.*?(\W|\S)//sg; $destination =~ s/;//sg; # remove path etc. $destination =~ m#http://(.*?)(/*$|/.*$)#; $destination = $1; print "Content-type: text/html\n\n"; print qq~