1 Wow, big hammer! [[patchqueue/Done]] though, with minor mods -- [[Joey]].
5 I consolidated all decode_utf8 in FormBuilder's fields
6 to make the code more readable and avoid future mistakes. The patch
7 seems to work and for the first time I have a UTF-8 username ;-)
8 I think that with this patch and the previous one about locales, we're
9 done with UTF-8 support. Yay!
12 ===================================================================
13 --- IkiWiki/CGI.pm (revision 904)
14 +++ IkiWiki/CGI.pm (working copy)
19 +sub decode_form_utf8 ($) { #{{{
21 + foreach my $f ($form->field) {
22 + next if Encode::is_utf8(scalar $form->field($f));
23 + $form->field(name => $f,
24 + value => decode_utf8($form->field($f)),
30 sub cgi_recentchanges ($) { #{{{
36 if ($form->submitted && $form->validate) {
37 + decode_form_utf8($form);
39 if ($form->submitted eq 'Login') {
40 $session->param("name", $form->field("name"));
41 if (defined $form->field("do") &&
43 value => userinfo_get($user_name, "locked_pages"));
46 + decode_form_utf8($form);
48 if ($form->submitted eq 'Logout') {
50 redirect($q, $config{url});
53 my @buttons=("Save Page", "Preview", "Cancel");
55 - # This untaint is safe because titlepage removes any problimatic
56 + # This untaint is safe because titlepage removes any problematic
58 my ($page)=decode_utf8($form->param('page'));
59 $page=titlepage(possibly_foolish_untaint(lc($page)));
64 + decode_form_utf8($form);
66 if ($form->submitted eq "Cancel") {
67 redirect($q, "$config{url}/".htmlpage($page));
70 elsif ($form->submitted eq "Preview") {
71 require IkiWiki::Render;
72 - # Apparently FormBuilder doesn't not treat input as
73 - # utf-8, so decode from it.
74 - my $content=decode_utf8($form->field('editcontent'));
75 - my $comments=decode_utf8($form->field('comments'));
76 + my $content=$form->field('editcontent');
77 + my $comments=$form->field('comments');
78 $form->field(name => "editcontent",
79 value => $content, force => 1);
80 $form->field(name => "comments",
83 page_locked($page, $session);
85 - # Decode utf-8 since FormBuilder does not
86 - my $content=decode_utf8($form->field('editcontent'));
87 + my $content=$form->field('editcontent');
89 $content=~s/\r\n/\n/g;
93 if (defined $form->field('comments') &&
94 length $form->field('comments')) {
95 - $message.=": ".decode_utf8($form->field('comments'));
96 + $message.=": ".$form->field('comments');
102 $form->tmpl_param("page_conflict", 1);
103 $form->field("editcontent", value => $conflict, force => 1);
104 - $form->field(name => "comments", value => decode_utf8($form->field('comments')), force => 1);
105 + $form->field(name => "comments", value => $form->field('comments'), force => 1);
106 $form->field("do", "edit)");
107 $form->tmpl_param("page_select", 0);
108 $form->field(name => "page", type => 'hidden');