* More utf-8 fixes from Recai, partly to things I broke above:
authorjoey <joey@0fa5a96a-9a0e-0410-b3b2-a0fd24251071>
Sat, 17 Jun 2006 01:44:19 +0000 (01:44 +0000)
committerjoey <joey@0fa5a96a-9a0e-0410-b3b2-a0fd24251071>
Sat, 17 Jun 2006 01:44:19 +0000 (01:44 +0000)
  - The serious problem is that writefile() saves the content in undecoded
    format in CGI, hence all (non-ascii) chars are corrupted permanently.
  - Comment field in edit page is not decoded and all the non-ascii chars in
    this field are corrupted as the result.  We should decode it as we do it
    for the content.

IkiWiki/CGI.pm
debian/changelog

index 0d763caa38ec942e540a1b36b5e579c08841c054..9d2ad8cdd11de28091449e7048b69d34a4eaace9 100644 (file)
@@ -43,7 +43,6 @@ sub cgi_recentchanges ($) { #{{{
                styleurl => styleurl(),
                baseurl => "$config{url}/",
        );
-       # XXX why is this needed? If it's raw utf-8 won't print DTRT?
        require Encode;
        print $q->header(-charset=>'utf-8'), Encode::decode_utf8($template->output);
 } #}}}
@@ -358,7 +357,10 @@ sub cgi_editpage ($$) { #{{{
                # utf-8, so decode from it.
                require Encode;
                my $content = Encode::decode_utf8($form->field('editcontent'));
-               $form->field(name => "editcontent", value => $content, force => 1);
+               $form->field(name => "editcontent",
+                               value => $content, force => 1);
+               $form->field(name => "comments",
+                               value => Encode::decode_utf8($form->field('comments')), force => 1);
                $form->tmpl_param("page_preview",
                        htmlize($config{default_pageext},
                                linkify($page, $page, $content)));
@@ -441,13 +443,17 @@ sub cgi_editpage ($$) { #{{{
                # save page
                page_locked($page, $session);
                
-               my $content=$form->field('editcontent');
+               # Decode utf-8 since FormBuilder does not
+               require Encode;
+               my $content=Encode::decode_utf8($form->field('editcontent'));
+
                $content=~s/\r\n/\n/g;
                $content=~s/\r/\n/g;
                writefile($file, $config{srcdir}, $content);
                
                my $message="web commit ";
-               if (length $session->param("name")) {
+               if (defined $session->param("name") && 
+                   length $session->param("name")) {
                        $message.="by ".$session->param("name");
                }
                else {
@@ -455,8 +461,6 @@ sub cgi_editpage ($$) { #{{{
                }
                if (defined $form->field('comments') &&
                    length $form->field('comments')) {
-                       # Decode utf-8 since FormBuilder does not.
-                       require Encode;
                        $message.=Encode::decode_utf8(": ".$form->field('comments'));
                }
                
index 5ee82efd825412682bc9bcde80e80c261d26cb35..a6312dc6656150e86fa012c109cb45301a10d742 100644 (file)
@@ -13,8 +13,14 @@ ikiwiki (1.6) UNRELEASED; urgency=low
   * Add utf-8 testcases for readfile and htmlize.
   * Put back the encode_utf8 in the input to markdown; it's really not utf-8
     safe.
-
- -- Joey Hess <joeyh@debian.org>  Fri, 16 Jun 2006 00:41:25 -0400
+  * More utf-8 fixes from Recai, partly to things I broke above:
+    - The serious problem is that writefile() saves the content in undecoded
+      format in CGI, hence all (non-ascii) chars are corrupted permanently.
+    - Comment field in edit page is not decoded and all the non-ascii chars in
+      this field are corrupted as the result.  We should decode it as we do it
+      for the content.
+
+ -- Joey Hess <joeyh@debian.org>  Fri, 16 Jun 2006 21:35:03 -0400
 
 ikiwiki (1.5) unstable; urgency=low