X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ian/git?p=cgi-auth-flexible.git;a=blobdiff_plain;f=cgi-auth-flexible.pm;h=1f44b8d23d74bb77a5e5140e2924091ce09b8353;hp=f4e0d6830a370b473650e1bb53d54a028a2be526;hb=f83d32c24e9f4f9ad8bbb3198e89e810d1f09435;hpb=0908f788ba5fd88725dd9324fb4488748c391d7e diff --git a/cgi-auth-flexible.pm b/cgi-auth-flexible.pm index f4e0d68..1f44b8d 100644 --- a/cgi-auth-flexible.pm +++ b/cgi-auth-flexible.pm @@ -1042,8 +1042,7 @@ sub url_with_query_params ($$;$) { my $uri = URI->new($r->_ch('get_url')); $uri->path($uri->path() . $params->{''}[0]) if $params->{''}; my @flatparams = flatten_params($params); - if (defined $nonpagetype - && $r->nonpage_get_needs_secret_hidden($nonpagetype)) { + if (defined $nonpagetype && $r->need_add_hidden('GET',$nonpagetype)) { push @flatparams, $r->{S}{assoc_param_name}, $r->secret_hidden_val(); } $uri->query_form(@flatparams); @@ -1078,7 +1077,7 @@ sub check_ok ($) { } if ($kind =~ m/^REDIRECT-/) { - # for redirects, we honour stored NextParams and SetCookie, + # for redirects, we honour stored Params and Cookie, # as we would for non-divert if ($kind eq 'REDIRECT-LOGGEDOUT') { $params->{$r->{S}{loggedout_param_names}[0]} = [ 1 ]; @@ -1286,25 +1285,29 @@ sub check_mutate ($) { $r->_must_be_post(); } -sub mutate_ok ($) { - my ($r) = @_; - $r->_assert_checked(); - die if $r->{Divert}; - return $r->_is_post(); -} - our %_resource_get_needs_secret_hidden = (map { $_ => 0 } qw(PAGE FRAME IFRAME SRCDUMP STYLESHEET FAVICON ROBOTS), map { $_ => 1 } qw(IMAGE SCRIPT AJAX-XML AJAX-JSON AJAX-OTHER)); -die todo make so can add new ones; +sub update_get_need_add_hidden ($$;$) { + my ($r, $reqtype, $value, $force) = @_; + my $hash = ref $r + ? ($r->{GetNeedsSecretHidden} ||= { }) + : \%_resource_get_needs_secret_hidden; + return if !$force && + (exists $_resource_get_needs_secret_hidden{$reqtype} || + exists $hash->{$reqtype}); + $hash->{$reqtype} = $value; +} sub need_add_hidden ($$) { my ($r, $method, $reqtype) = @_; return 1 if $method ne 'GET'; + my $ent = $r->{GetNeedsSecretHidden}{$reqtype}; + return $ent if defined $ent; my $ent = $_resource_get_needs_secret_hidden{$reqtype}; - die "unsupported nonpage GET type $reqtype" unless defined $ent; - return $ent; + return $ent if defined $ent; + die "unsupported nonpage GET type $reqtype"; } sub check_nonpage ($$) {