Location.pm is a redirector that expects to find a URL on a query string value assigned to location, it deals with the hex unescaping and issues the redirect.

Location.pm consists only of the following 18 lines of Perl:

package Location;
use strict;
use Apache::Constants qw(REDIRECT);

sub handler {
   my $r=Apache->request;
   $ENV{'QUERY_STRING'}=$r->args;
   my($dest)=(grep(/^location=/,split(/\&/,$ENV{'QUERY_STRING'})))
      or $ENV{'QUERY_STRING'};
   $dest=~s/^location=//;
   $dest=~s/%(..)/pack("c",hex($1))/ge;
   $r->status(302);
   $r->header_out(Location=>$dest);
   $r->send_http_header;
   return REDIRECT;
} # handler
1;

Slide 17 of 19 Contents
  1 |   2 |   3 |   4 |   5 |   6 |   7 |   8 |   9 | 10
11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19
www.arachna.com > Educational Resources > Conference Presentations

spidaman
© 1999-2009 Ian Kallen | Copyright Notice