]> sipb.mit.edu Git - ikiwiki.git/commitdiff
* Stop testing Encode::is_utf8 in decode_form_utf8: That doesn't work.
authorJoey Hess <joey@kodama.kitenet.net>
Wed, 2 Jan 2008 00:58:45 +0000 (19:58 -0500)
committerJoey Hess <joey@kodama.kitenet.net>
Wed, 2 Jan 2008 00:58:45 +0000 (19:58 -0500)
* 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.

IkiWiki/CGI.pm
debian/changelog

index c2dacf78d46253a74015cd67155bbb33fc34ad70..35c62ce3ea1900b728b742c0ab7c7c011fef0684 100644 (file)
@@ -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);
index 1fe89256c3838496ce716f604b0ef6bf814bbf9e..6bb5f0076758a821c3fe1b77890c60a0900eef47 100644 (file)
@@ -3,6 +3,14 @@ ikiwiki (2.18) UNRELEASED; urgency=low
   * 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