]> sipb.mit.edu Git - ikiwiki.git/commitdiff
Perls older than 5.10 need to use the old method of decoding utf-8 in CGI values...
authorJoey Hess <joey@kodama.kitenet.net>
Wed, 21 May 2008 19:30:56 +0000 (15:30 -0400)
committerJoey Hess <joey@kodama.kitenet.net>
Wed, 21 May 2008 19:30:56 +0000 (15:30 -0400)
IkiWiki/CGI.pm
debian/changelog

index 1ec0128fec21b26387079b2544882fc92c99facd..532f9c5f6f85f88ea57e00ec98fdc0d603d7520c 100644 (file)
@@ -77,13 +77,25 @@ sub check_canedit ($$$;$) { #{{{
        return $canedit;
 } #}}}
 
+sub decode_cgi_utf8 ($) { #{{{
+       # decode_form_utf8 method is needed for 5.10
+       if ($] < 5.01) {
+               my $cgi = shift;
+               foreach my $f ($cgi->param) {
+                       $cgi->param($f, map { decode_utf8 $_ } $cgi->param($f));
+               }
+       }
+} #}}}
+
 sub decode_form_utf8 ($) { #{{{
-       my $form = shift;
-       foreach my $f ($form->field) {
-               $form->field(name  => $f,
-                            value => decode_utf8($form->field($f)),
-                            force => 1,
-               );
+       if ($] >= 5.01) {
+               my $form = shift;
+               foreach my $f ($form->field) {
+                       $form->field(name  => $f,
+                                    value => decode_utf8($form->field($f)),
+                                    force => 1,
+                       );
+               }
        }
 } #}}}
 
@@ -106,6 +118,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(
@@ -165,6 +178,7 @@ sub cgi_prefs ($$) { #{{{
        my $session=shift;
 
        needsignin($q, $session);
+       decode_cgi_utf8($q);
        
        # The session id is stored on the form and checked to
        # guard against CSRF.
@@ -260,6 +274,8 @@ sub cgi_editpage ($$) { #{{{
        my $q=shift;
        my $session=shift;
        
+       decode_cgi_utf8($q);
+
        my @fields=qw(do rcsinfo subpage from page type editcontent comments);
        my @buttons=("Save Page", "Preview", "Cancel");
        eval q{use CGI::FormBuilder};
index d80ede67de0b318eab8ccda5018e34b962174739..c4919584da5586adee3355b60c8d023f7d49039a 100644 (file)
@@ -13,6 +13,9 @@ ikiwiki (2.47) UNRELEASED; urgency=low
     when generating recentchanges.
   * ENV can be used in the setup file to override environment variable
     settings, such as TZ or PATH.
+  * Perls older than 5.10 need to use the old method of decoding utf-8 in CGI
+    values. Neither method will work for all versions of perl, so check
+    version number at runtime.
 
  -- Joey Hess <joeyh@debian.org>  Tue, 13 May 2008 12:30:18 -0400