Ignore:
Timestamp:
07/27/10 13:15:56 (14 years ago)
Author:
Kris Deugau
Message:

/branches/htmlform

Switch all scripts to use CGI::Simple for HTML form data munging
instead of legacy CommonWeb.pm sub. Remove parse_post() sub from
CommonWeb.pm. See #15.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/htmlform/cgi-bin/CommonWeb.pm

    r415 r447  
    1616$VERSION     = 1.00;
    1717@ISA         = qw(Exporter);
    18 @EXPORT_OK      = qw(&parse_post &printFooter &printHeader &printError &printAndExit &desanitize &cleanInput &desanitize);
     18@EXPORT_OK      = qw(&printFooter &printHeader &printError &printAndExit &desanitize &cleanInput &desanitize);
    1919
    2020@EXPORT      = (); #export nothing by default
    21 %EXPORT_TAGS = ( ALL => [qw( &parse_post &printFooter &printHeader &printError
     21%EXPORT_TAGS = ( ALL => [qw( &printFooter &printHeader &printError
    2222                                &printAndExit &desanitize &cleanInput )],
    23                  lean    => [qw( &parse_post &printFooter &printHeader &printError
     23                 lean    => [qw( &printFooter &printHeader &printError
    2424                                &printAndExit &cleanInput )]
    2525                );
    26 
    27 sub parse_post {
    28   my $buffer;
    29   if ($ENV{'REQUEST_METHOD'} eq "GET") {
    30     $buffer=$ENV{'QUERY_STRING'}
    31   } elsif ($ENV{'REQUEST_METHOD'} eq 'POST' && $ENV{'CONTENT_TYPE'} eq "application/x-www-form-urlencoded") {
    32     read(STDIN, $buffer, $ENV{CONTENT_LENGTH});
    33   } else {
    34     $buffer = $ENV{'QUERY_STRING'};
    35     $buffer || read(STDIN, $buffer, $ENV{CONTENT_LENGTH});
    36   }
    37   my @pairs = split(/&/, $buffer);
    38   my %webvarLocal;
    39   foreach my $pair (@pairs) {
    40     my ($name, $value) = split(/=/, $pair);
    41     $name  =~ tr/+/ /;
    42     $name  =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
    43     $value =~ tr/+/ /;
    44     $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
    45     $value =~ s/\'/\\\'/g;
    46     $webvarLocal{$name} = $value;
    47   }
    48   return %webvarLocal;
    49 }
    5026
    5127
Note: See TracChangeset for help on using the changeset viewer.