From ab11625025348dd2f0b4324413463358f52aede3 Mon Sep 17 00:00:00 2001 From: Sebastian Riedel Date: Fri, 10 Sep 2004 10:17:15 +0000 Subject: [PATCH] fixed multiple value handling git-svn-id: http://svn.maypole.perl.org/Maypole/trunk@173 48953598-375a-da11-a14b-00016c27c3ee --- Changes | 1 + lib/CGI/Maypole.pm | 49 +++++++++++++++++++++++++--------------------- 2 files changed, 28 insertions(+), 22 deletions(-) diff --git a/Changes b/Changes index 1b2bc76..ac6493a 100644 --- a/Changes +++ b/Changes @@ -7,6 +7,7 @@ Revision history for Perl extension Maypole - added Maypole::Application universal loader - config parameter handling for Maypole::Model::CDBI - $r->{query} is now deprecated, use $r->{params} for GET and POST + - fixed multiple value handling (Simon Flack) 1.7 Sat Jul 17 20:15:26 BST 2004 - Emergency release - we lost the "use Maypole::Constants" from diff --git a/lib/CGI/Maypole.pm b/lib/CGI/Maypole.pm index 88995ef..e112913 100644 --- a/lib/CGI/Maypole.pm +++ b/lib/CGI/Maypole.pm @@ -6,45 +6,50 @@ use warnings; our $VERSION = "0.3"; sub run { - my $self = shift; - return $self->handler(); + my $self = shift; + return $self->handler(); } sub get_request { - require CGI::Simple; - shift->{cgi} = CGI::Simple->new(); + require CGI::Simple; + shift->{cgi} = CGI::Simple->new(); } sub parse_location { - my $self = shift; - $self->{path} = $self->{cgi}->url(-absolute=>1, -path_info=>1); - my $loc = $self->{cgi}->url(-absolute=>1); - no warnings 'uninitialized'; - $self->{path} =~ s/^($loc)?\///; - $self->parse_path; - $self->parse_args; + my $self = shift; + $self->{path} = $self->{cgi}->url( -absolute => 1, -path_info => 1 ); + my $loc = $self->{cgi}->url( -absolute => 1 ); + no warnings 'uninitialized'; + $self->{path} =~ s/^($loc)?\///; + $self->parse_path; + $self->parse_args; } sub parse_args { - my $self = shift; - $self->{params} = { $self->{cgi}->Vars }; - $self->{query} = { $self->{cgi}->Vars }; + my $self = shift; + my (%vars) = $self->{cgi}->Vars; + while ( my ( $key, $value ) = each %vars ) { + my @values = split "\0", $value; + $vars{$key} = @values == 1 ? $values[0] : \@values; + } + $self->{params} = {%vars}; + $self->{query} = {%vars}; } sub send_output { - my $r = shift; - print $r->{cgi}->header(-type => $r->{content_type}, - -content_length => length $r->{output}, - ); - print $r->{output}; + my $r = shift; + print $r->{cgi}->header( + -type => $r->{content_type}, + -content_length => length $r->{output}, + ); + print $r->{output}; } sub get_template_root { - my $r = shift; - $r->{cgi}->document_root . "/". $r->{cgi}->url(-relative=>1); + my $r = shift; + $r->{cgi}->document_root . "/" . $r->{cgi}->url( -relative => 1 ); } - 1; =head1 NAME -- 2.39.2