X-Git-Url: http://git.vanrenterghem.biz/git.ikiwiki.info.git/blobdiff_plain/1dddec0ba9f66f082f4b8349916cdb6bdb5636e3..de468ba12dfc0891145b3f8b432eb97b70b60c0c:/IkiWiki/CGI.pm diff --git a/IkiWiki/CGI.pm b/IkiWiki/CGI.pm index 8a294e887..99cead64f 100644 --- a/IkiWiki/CGI.pm +++ b/IkiWiki/CGI.pm @@ -281,7 +281,6 @@ sub cgi_editpage ($$) { #{{{ eval q{use CGI::FormBuilder}; error($@) if $@; my $form = CGI::FormBuilder->new( - title => "editpage", fields => \@fields, charset => "utf-8", method => 'POST', @@ -302,10 +301,9 @@ sub cgi_editpage ($$) { #{{{ }); decode_form_utf8($form); - # This untaint is safe because titlepage removes any problematic - # characters. - my ($page)=$form->field('page'); - $page=titlepage(possibly_foolish_untaint($page)); + # This untaint is safe because we check file_pruned. + my $page=$form->field('page'); + $page=possibly_foolish_untaint($page); if (! defined $page || ! length $page || file_pruned($page, $config{srcdir}) || $page=~/^\//) { error("bad page name"); @@ -355,7 +353,7 @@ sub cgi_editpage ($$) { #{{{ $form->field(name => "from", type => 'hidden'); $form->field(name => "rcsinfo", type => 'hidden'); $form->field(name => "subpage", type => 'hidden'); - $form->field(name => "page", value => pagetitle($page, 1), force => 1); + $form->field(name => "page", value => $page, force => 1); $form->field(name => "type", value => $type, force => 1); $form->field(name => "comments", type => "text", size => 80); $form->field(name => "editcontent", type => "textarea", rows => 20, @@ -396,11 +394,17 @@ sub cgi_editpage ($$) { #{{{ session => $session, ); }); - $form->tmpl_param("page_preview", - htmlize($page, $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}; @@ -481,8 +485,8 @@ sub cgi_editpage ($$) { #{{{ $form->tmpl_param("page_select", 1); $form->field(name => "page", type => 'select', - options => [ map { pagetitle($_, 1) } @editable_locs ], - value => pagetitle($best_loc, 1)); + options => [ map { [ $_, pagetitle($_, 1) ] } @editable_locs ], + value => $best_loc); $form->field(name => "type", type => 'select', options => \@page_types); $form->title(sprintf(gettext("creating %s"), pagetitle($page))); @@ -661,10 +665,11 @@ sub cgi (;$$) { #{{{ my $q=shift; my $session=shift; + eval q{use CGI}; + error($@) if $@; + $CGI::DISABLE_UPLOADS=$config{cgi_disable_uploads}; + if (! $q) { - eval q{use CGI}; - error($@) if $@; - binmode(STDIN); $q=CGI->new; binmode(STDIN, ":utf8");