X-Git-Url: https://sipb.mit.edu/gitweb.cgi/ikiwiki.git/blobdiff_plain/f5eb3df1fab53ed6fe1359a8d6a339a321626db8..929b9de9c2b0f3ed1a0c9e006d084519bd5e0479:/IkiWiki/CGI.pm diff --git a/IkiWiki/CGI.pm b/IkiWiki/CGI.pm index 9d2ad8cdd..73afe2468 100644 --- a/IkiWiki/CGI.pm +++ b/IkiWiki/CGI.pm @@ -4,6 +4,8 @@ use warnings; use strict; use IkiWiki; use IkiWiki::UserInfo; +use encoding 'utf8'; # force use of utf8 for io layer +use Encode; package IkiWiki; @@ -32,9 +34,7 @@ sub cgi_recentchanges ($) { #{{{ unlockwiki(); - my $template=HTML::Template->new( - filename => "$config{templatedir}/recentchanges.tmpl" - ); + my $template=template("recentchanges.tmpl"); $template->param( title => "RecentChanges", indexlink => indexlink(), @@ -43,8 +43,7 @@ sub cgi_recentchanges ($) { #{{{ styleurl => styleurl(), baseurl => "$config{url}/", ); - require Encode; - print $q->header(-charset=>'utf-8'), Encode::decode_utf8($template->output); + print $q->header(-charset=>'utf-8'), $template->output; } #}}} sub cgi_signin ($$) { #{{{ @@ -70,7 +69,7 @@ sub cgi_signin ($$) { #{{{ action => $config{cgiurl}, header => 0, template => (-e "$config{templatedir}/signin.tmpl" ? - "$config{templatedir}/signin.tmpl" : ""), + {template_params("signin.tmpl")} : ""), stylesheet => styleurl(), ); @@ -183,9 +182,7 @@ sub cgi_signin ($$) { #{{{ } elsif ($form->submitted eq 'Mail Password') { my $user_name=$form->field("name"); - my $template=HTML::Template->new( - filename => "$config{templatedir}/passwordmail.tmpl" - ); + my $template=template("passwordmail.tmpl"); $template->param( user_name => $user_name, user_password => userinfo_get($user_name, "password"), @@ -237,7 +234,7 @@ sub cgi_prefs ($$) { #{{{ params => $q, action => $config{cgiurl}, template => (-e "$config{templatedir}/prefs.tmpl" ? - "$config{templatedir}/prefs.tmpl" : ""), + {template_params("prefs.tmpl")} : ""), stylesheet => styleurl(), ); my @buttons=("Save Preferences", "Logout", "Cancel"); @@ -306,13 +303,14 @@ sub cgi_editpage ($$) { #{{{ params => $q, action => $config{cgiurl}, table => 0, - template => "$config{templatedir}/editpage.tmpl" + template => {template_params("editpage.tmpl")}, ); my @buttons=("Save Page", "Preview", "Cancel"); # This untaint is safe because titlepage removes any problimatic # characters. - my ($page)=titlepage(possibly_foolish_untaint(lc($form->param('page')))); + my ($page)=Encode::decode_utf8($form->param('page')); + $page=titlepage(possibly_foolish_untaint(lc($page))); if (! defined $page || ! length $page || $page=~/$config{wiki_file_prune_regexp}/ || $page=~/^\//) { error("bad page name"); @@ -355,12 +353,12 @@ sub cgi_editpage ($$) { #{{{ require IkiWiki::Render; # Apparently FormBuilder doesn't not treat input as # utf-8, so decode from it. - require Encode; my $content = Encode::decode_utf8($form->field('editcontent')); + my $comments = Encode::decode_utf8($form->field('comments')); $form->field(name => "editcontent", value => $content, force => 1); $form->field(name => "comments", - value => Encode::decode_utf8($form->field('comments')), force => 1); + value => $comments, force => 1); $form->tmpl_param("page_preview", htmlize($config{default_pageext}, linkify($page, $page, $content))); @@ -444,7 +442,6 @@ sub cgi_editpage ($$) { #{{{ page_locked($page, $session); # Decode utf-8 since FormBuilder does not - require Encode; my $content=Encode::decode_utf8($form->field('editcontent')); $content=~s/\r\n/\n/g; @@ -461,7 +458,7 @@ sub cgi_editpage ($$) { #{{{ } if (defined $form->field('comments') && length $form->field('comments')) { - $message.=Encode::decode_utf8(": ".$form->field('comments')); + $message.=": ".Encode::decode_utf8($form->field('comments')); } if ($config{rcs}) { @@ -480,6 +477,7 @@ sub cgi_editpage ($$) { #{{{ force => 1); $form->tmpl_param("page_conflict", 1); $form->field("editcontent", value => $conflict, force => 1); + $form->field(name => "comments", value => Encode::decode_utf8($form->field('comments')), force => 1); $form->field("do", "edit)"); $form->tmpl_param("page_select", 0); $form->field(name => "page", type => 'hidden');