X-Git-Url: http://git.vanrenterghem.biz/git.ikiwiki.info.git/blobdiff_plain/fb3d5b480085fff26e4d7af3e915615144950511..0f8ea7ecca27a9e73af5c515f637f543912c7076:/IkiWiki/CGI.pm diff --git a/IkiWiki/CGI.pm b/IkiWiki/CGI.pm index 5fccfb474..0d010b115 100644 --- a/IkiWiki/CGI.pm +++ b/IkiWiki/CGI.pm @@ -6,6 +6,8 @@ use IkiWiki; use IkiWiki::UserInfo; use open qw{:utf8 :std}; use Encode; +use CGI; +$CGI::DISABLE_UPLOADS=1; package IkiWiki; @@ -77,13 +79,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 +120,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 +180,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,12 +276,13 @@ 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}; error($@) if $@; my $form = CGI::FormBuilder->new( - title => "editpage", fields => \@fields, charset => "utf-8", method => 'POST', @@ -380,11 +397,17 @@ sub cgi_editpage ($$) { #{{{ session => $session, ); }); - $form->tmpl_param("page_preview", - htmlize($page, $type, + my $preview=htmlize($page, $page, $type, linkify($page, $page, preprocess($page, $page, - filter($page, $page, $content), 0, 1)))); + filter($page, $page, $content), 0, 1))); + run_hooks(format => sub { + $preview=shift->( + page => $page, + content => $preview, + ); + }); + $form->tmpl_param("page_preview", $preview); if ($new) { delete $pagesources{$page}; @@ -621,6 +644,7 @@ sub cgi_getsession ($) { #{{{ my $q=shift; eval q{use CGI::Session}; + error($@) if $@; CGI::Session->name("ikiwiki_session_".encode_utf8($config{wikiname})); my $oldmask=umask(077); @@ -645,9 +669,6 @@ sub cgi (;$$) { #{{{ my $session=shift; if (! $q) { - eval q{use CGI}; - error($@) if $@; - binmode(STDIN); $q=CGI->new; binmode(STDIN, ":utf8");