aboutsummaryrefslogtreecommitdiff
path: root/IkiWiki/CGI.pm
diff options
context:
space:
mode:
authorJoey Hess <joey@kodama.kitenet.net>2008-01-01 19:58:45 -0500
committerJoey Hess <joey@kodama.kitenet.net>2008-01-01 19:58:45 -0500
commit57bba4dac132a06729eeec809f5e1a5adf829806 (patch)
tree01e8dc78a0fdcfd246cb03c3b0a8387d203ecaec /IkiWiki/CGI.pm
parenta22dfe6fef499cf6bf9c678596025172e6bc61d8 (diff)
downloadikiwiki-57bba4dac132a06729eeec809f5e1a5adf829806.tar
ikiwiki-57bba4dac132a06729eeec809f5e1a5adf829806.tar.gz
* 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.
Diffstat (limited to 'IkiWiki/CGI.pm')
-rw-r--r--IkiWiki/CGI.pm21
1 files changed, 7 insertions, 14 deletions
diff --git a/IkiWiki/CGI.pm b/IkiWiki/CGI.pm
index c2dacf78d..35c62ce3e 100644
--- a/IkiWiki/CGI.pm
+++ b/IkiWiki/CGI.pm
@@ -71,14 +71,10 @@ sub check_canedit ($$$;$) { #{{{
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));
}
} #}}}
@@ -150,6 +146,7 @@ sub cgi_signin ($$) { #{{{
my $q=shift;
my $session=shift;
+ decode_cgi_utf8($q);
eval q{use CGI::FormBuilder};
error($@) if $@;
my $form = CGI::FormBuilder->new(
@@ -173,8 +170,6 @@ sub cgi_signin ($$) { #{{{
$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);
@@ -212,6 +207,7 @@ sub cgi_prefs ($$) { #{{{
needsignin($q, $session);
+ decode_cgi_utf8($q);
eval q{use CGI::FormBuilder};
error($@) if $@;
my $form = CGI::FormBuilder->new(
@@ -237,8 +233,6 @@ sub cgi_prefs ($$) { #{{{
);
my $buttons=["Save Preferences", "Logout", "Cancel"];
- decode_form_utf8($form);
-
run_hooks(formbuilder_setup => sub {
shift->(form => $form, cgi => $q, session => $session,
buttons => $buttons);
@@ -303,6 +297,7 @@ sub cgi_editpage ($$) { #{{{
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(
@@ -320,8 +315,6 @@ sub cgi_editpage ($$) { #{{{
wikiname => $config{wikiname},
);
- decode_form_utf8($form);
-
run_hooks(formbuilder_setup => sub {
shift->(form => $form, cgi => $q, session => $session,
buttons => \@buttons);