From: Ian Jackson Date: Fri, 11 Jan 2013 16:47:39 +0000 (+0000) Subject: wip, finish path handling, seems to work well now X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ian/git?p=cgi-auth-flexible.git;a=commitdiff_plain;h=af3159edbfe74d267bb6441c1e7dc7360168ad6e wip, finish path handling, seems to work well now --- diff --git a/cgi-auth-flexible.pm b/cgi-auth-flexible.pm index 00b766a..af4c30b 100644 --- a/cgi-auth-flexible.pm +++ b/cgi-auth-flexible.pm @@ -54,6 +54,7 @@ sub flatten_params ($) { my ($p) = @_; my @p; foreach my $k (keys %$p) { + next if $k eq ''; foreach my $v (@{ $p->{$k} }) { push @p, $k, $v; } @@ -113,10 +114,13 @@ sub gen_some_form ($$) { # Calls $bodyfn->($c,$r) which returns @formbits my $c = $r->{Cgi}; my @form; + my $pathinfo = ''; + $pathinfo .= $params->{''}[0] if $params->{''}; push @form, ('
'); + escapeHTML($r->_ch('get_url').$pathinfo).'">'); push @form, $bodyfn->($c,$r); foreach my $n (keys %$params) { + next if $n eq ''; foreach my $val (@{ $params->{$n} }) { push @form, (' 0, get_param => sub { $_[0]->param($_[2]) }, get_params => sub { $_[1]->get_params() }, + get_path_info => sub { $_[0]->path_info() }, get_cookie => sub { $_[0]->cookie($_[1]->{S}{cookie_name}) }, get_method => sub { $_[0]->request_method() }, get_url => sub { $_[0]->url(); }, @@ -619,6 +624,8 @@ sub chain_params ($) { foreach my $name (grep /^$dummy_prefix/, keys %p) { delete $p{$name}; } + die if exists $p{''}; + $p{''} = [ $r->_ch('get_path_info') ]; return \%p; } @@ -722,6 +729,7 @@ sub url_with_query_params ($$) { my ($r, $params) = @_; print STDERR "PARAMS ",Dumper($params); my $uri = URI->new($r->_ch('get_url')); + $uri->path($uri->path() . $params->{''}[0]) if $params->{''}; $uri->query_form(flatten_params($params)); return $uri->as_string(); } @@ -748,10 +756,6 @@ sub check_ok ($) { my $params = $divert->{Params}; my $cookie = $r->construct_cookie($cookiesecret); - if (defined $cookiesecret) { - $params->{$r->{S}{assoc_param_name}} = [ $r->hash($cookiesecret) ]; - } - if ($kind =~ m/^REDIRECT-/) { # for redirects, we honour stored NextParams and SetCookie, # as we would for non-divert @@ -768,6 +772,10 @@ sub check_ok ($) { return 0; } + if (defined $cookiesecret) { + $params->{$r->{S}{assoc_param_name}} = [ $r->hash($cookiesecret) ]; + } + my ($title, @body); if ($kind =~ m/^LOGIN-/) { $title = $r->_gt('Login');