3 I consolidated all decode_utf8 in FormBuilder's fields
4 to make the code more readable and avoid future mistakes. The patch
5 seems to work and for the first time I have a UTF-8 username ;-)
6 I think that with this patch and the previous one about locales, we're
7 done with UTF-8 support. Yay!
10 ===================================================================
11 --- IkiWiki/CGI.pm (revision 904)
12 +++ IkiWiki/CGI.pm (working copy)
17 +sub decode_form_utf8 ($) { #{{{
19 + foreach my $f ($form->field) {
20 + next if Encode::is_utf8(scalar $form->field($f));
21 + $form->field(name => $f,
22 + value => decode_utf8($form->field($f)),
28 sub cgi_recentchanges ($) { #{{{
34 if ($form->submitted && $form->validate) {
35 + decode_form_utf8($form);
37 if ($form->submitted eq 'Login') {
38 $session->param("name", $form->field("name"));
39 if (defined $form->field("do") &&
41 value => userinfo_get($user_name, "locked_pages"));
44 + decode_form_utf8($form);
46 if ($form->submitted eq 'Logout') {
48 redirect($q, $config{url});
51 my @buttons=("Save Page", "Preview", "Cancel");
53 - # This untaint is safe because titlepage removes any problimatic
54 + # This untaint is safe because titlepage removes any problematic
56 my ($page)=decode_utf8($form->param('page'));
57 $page=titlepage(possibly_foolish_untaint(lc($page)));
62 + decode_form_utf8($form);
64 if ($form->submitted eq "Cancel") {
65 redirect($q, "$config{url}/".htmlpage($page));
68 elsif ($form->submitted eq "Preview") {
69 require IkiWiki::Render;
70 - # Apparently FormBuilder doesn't not treat input as
71 - # utf-8, so decode from it.
72 - my $content=decode_utf8($form->field('editcontent'));
73 - my $comments=decode_utf8($form->field('comments'));
74 + my $content=$form->field('editcontent');
75 + my $comments=$form->field('comments');
76 $form->field(name => "editcontent",
77 value => $content, force => 1);
78 $form->field(name => "comments",
81 page_locked($page, $session);
83 - # Decode utf-8 since FormBuilder does not
84 - my $content=decode_utf8($form->field('editcontent'));
85 + my $content=$form->field('editcontent');
87 $content=~s/\r\n/\n/g;
91 if (defined $form->field('comments') &&
92 length $form->field('comments')) {
93 - $message.=": ".decode_utf8($form->field('comments'));
94 + $message.=": ".$form->field('comments');
100 $form->tmpl_param("page_conflict", 1);
101 $form->field("editcontent", value => $conflict, force => 1);
102 - $form->field(name => "comments", value => decode_utf8($form->field('comments')), force => 1);
103 + $form->field(name => "comments", value => $form->field('comments'), force => 1);
104 $form->field("do", "edit)");
105 $form->tmpl_param("page_select", 0);
106 $form->field(name => "page", type => 'hidden');