X-Git-Url: http://git.shiar.net/perl/plp/.git/blobdiff_plain/b76b015b41c31d18044c5f95b4416329ba1507db..a5521fb1820cc67ab3d7c0fe728ef36b0b379a3f:/PLP/Fields.pm diff --git a/PLP/Fields.pm b/PLP/Fields.pm index 3dda7d3..2a4190c 100644 --- a/PLP/Fields.pm +++ b/PLP/Fields.pm @@ -6,63 +6,63 @@ use strict; # and %header in PLP::Script. Also generates %cookie immediately. sub doit { - # %get - - my $get = \%PLP::Script::get; - if (length $ENV{QUERY_STRING}){ - for (split /[&;]/, $ENV{QUERY_STRING}) { - my @keyval = split /=/, $_, 2; - PLP::Functions::DecodeURI(@keyval); - $get->{$keyval[0]} = $keyval[1] unless $keyval[0] =~ /^\@/; - push @{ $get->{ '@' . $keyval[0] } }, $keyval[1]; - } - } - - # %post - - tie %PLP::Script::post, 'PLP::Tie::Delay', 'PLP::Script::post', sub { - my %post; - my $post; - - return \%post if $ENV{CONTENT_TYPE} !~ - m!^(?:application/x-www-form-urlencoded|$)!; - - if ($ENV{MOD_PERL}) { - $post = Apache->request->content; - } else { - read *STDIN, $post, $ENV{CONTENT_LENGTH}; - } - - return \%post unless defined $post and length $post; + # %get - for (split /&/, $post) { - my @keyval = split /=/, $_, 2; - PLP::Functions::DecodeURI(@keyval); - $post{$keyval[0]} = $keyval[1] unless $keyval[0] =~ /^\@/; - push @{ $post{ '@' . $keyval[0] } }, $keyval[1]; + my $get = \%PLP::Script::get; + if (length $ENV{QUERY_STRING}){ + for (split /[&;]/, $ENV{QUERY_STRING}) { + my @keyval = split /=/, $_, 2; + PLP::Functions::DecodeURI(@keyval); + $get->{$keyval[0]} = $keyval[1] unless $keyval[0] =~ /^\@/; + push @{ $get->{ '@' . $keyval[0] } }, $keyval[1]; + } } - - return \%post; - }; - - # %fields - - tie %PLP::Script::fields, 'PLP::Tie::Delay', 'PLP::Script::fields', sub { - return { %PLP::Script::get, %PLP::Script::post }; - }; - - # %header - - tie %PLP::Script::header, 'PLP::Tie::Headers'; - - # %cookie - if (defined $ENV{HTTP_COOKIE} and length $ENV{HTTP_COOKIE}) { - for (split /; ?/, $ENV{HTTP_COOKIE}) { - my @keyval = split /=/, $_, 2; - $PLP::Script::cookie{$keyval[0]} ||= $keyval[1]; + # %post + + tie %PLP::Script::post, 'PLP::Tie::Delay', 'PLP::Script::post', sub { + my %post; + my $post; + + return \%post if $ENV{CONTENT_TYPE} !~ + m!^(?:application/x-www-form-urlencoded|$)!; + + if ($ENV{MOD_PERL}) { + $post = Apache->request->content; + } else { + read *STDIN, $post, $ENV{CONTENT_LENGTH}; + } + + return \%post unless defined $post and length $post; + + for (split /&/, $post) { + my @keyval = split /=/, $_, 2; + PLP::Functions::DecodeURI(@keyval); + $post{$keyval[0]} = $keyval[1] unless $keyval[0] =~ /^\@/; + push @{ $post{ '@' . $keyval[0] } }, $keyval[1]; + } + + return \%post; + }; + + # %fields + + tie %PLP::Script::fields, 'PLP::Tie::Delay', 'PLP::Script::fields', sub { + return { %PLP::Script::get, %PLP::Script::post }; + }; + + # %header + + tie %PLP::Script::header, 'PLP::Tie::Headers'; + + # %cookie + + if (defined $ENV{HTTP_COOKIE} and length $ENV{HTTP_COOKIE}) { + for (split /; ?/, $ENV{HTTP_COOKIE}) { + my @keyval = split /=/, $_, 2; + $PLP::Script::cookie{$keyval[0]} ||= $keyval[1]; + } } - } } 1;