return $canedit;
} #}}}
-sub decode_form_utf8 ($) { #{{{
- my $form = shift;
- foreach my $f ($form->field) {
- next if Encode::is_utf8(scalar $form->field($f));
- $form->field(name => $f,
- value => decode_utf8($form->field($f)),
- force => 1,
- );
+sub decode_cgi_utf8 ($) { #{{{
+ my $cgi = shift;
+ foreach my $f ($cgi->param) {
+ $cgi->param($f, map { decode_utf8 $_ } $cgi->param($f));
}
} #}}}
my $q=shift;
my $session=shift;
+ decode_cgi_utf8($q);
eval q{use CGI::FormBuilder};
error($@) if $@;
my $form = CGI::FormBuilder->new(
$form->field(name => "do", type => "hidden", value => "signin",
force => 1);
- decode_form_utf8($form);
-
run_hooks(formbuilder_setup => sub {
shift->(form => $form, cgi => $q, session => $session,
buttons => $buttons);
needsignin($q, $session);
+ decode_cgi_utf8($q);
eval q{use CGI::FormBuilder};
error($@) if $@;
my $form = CGI::FormBuilder->new(
);
my $buttons=["Save Preferences", "Logout", "Cancel"];
- decode_form_utf8($form);
-
run_hooks(formbuilder_setup => sub {
shift->(form => $form, cgi => $q, session => $session,
buttons => $buttons);
my @fields=qw(do rcsinfo subpage from page type editcontent comments);
my @buttons=("Save Page", "Preview", "Cancel");
+ decode_cgi_utf8($q);
eval q{use CGI::FormBuilder};
error($@) if $@;
my $form = CGI::FormBuilder->new(
wikiname => $config{wikiname},
);
- decode_form_utf8($form);
-
run_hooks(formbuilder_setup => sub {
shift->(form => $form, cgi => $q, session => $session,
buttons => \@buttons);
* Split error messages for failures to drop real uid and gid.
* Retry dropping uid and gid, possibly this will help with the "Resource
temporarily unavailable" failures I've experienced under xen.
+ * Stop testing Encode::is_utf8 in decode_form_utf8: That doesn't work.
+ * decode_form_utf8 only fixed the utf-8 encoding for fields that were
+ registered at the time it was called, which was before the
+ formbuilder_setup hook. Fields added by the hook didn't get decoded.
+ But it can't be put after the hook either, since plugins using the hook
+ need to be able to use form values. To fix this dilemma, it's been changed
+ to a decode_cgi_utf8, which is called on the cgi query object, before the
+ form is set up, and decodes *all* cgi parameters.
-- Joey Hess <joeyh@debian.org> Tue, 01 Jan 2008 18:46:59 -0500