From: Joey Hess Date: Sat, 27 Sep 2008 17:00:48 +0000 (-0400) Subject: Merge commit 'smcv/beautify' X-Git-Tag: 2.66~67 X-Git-Url: http://git.vanrenterghem.biz/git.ikiwiki.info.git/commitdiff_plain/7351d545d96df3c1359312b1a5b79530fa6ab4fd?hp=-c Merge commit 'smcv/beautify' Conflicts: IkiWiki/Plugin/recentchanges.pm Note that smcv's approach of using urlto also gets the url right when redirecting to a non-html file, which is a better approach than my recent fix to recentchanges --- 7351d545d96df3c1359312b1a5b79530fa6ab4fd diff --combined IkiWiki/Plugin/editpage.pm index 68f43bf16,e07052497..687ebf51e --- a/IkiWiki/Plugin/editpage.pm +++ b/IkiWiki/Plugin/editpage.pm @@@ -85,9 -85,8 +85,9 @@@ sub cgi_editpage ($$) { #{{ }); decode_form_utf8($form); - # This untaint is safe because we check file_pruned. - my $page=$form->field('page'); + # This untaint is safe because we check file_pruned and + # wiki_file_regexp. + my ($page)=$form->field('page')=~/$config{wiki_file_regexp}/; $page=possibly_foolish_untaint($page); my $absolute=($page =~ s#^/+##); if (! defined $page || ! length $page || @@@ -95,8 -94,8 +95,8 @@@ error("bad page name"); } - my $baseurl=$config{url}."/".htmlpage($page); - + my $baseurl = urlto($page, undef, 1); + my $from; if (defined $form->field('from')) { ($from)=$form->field('from')=~/$config{wiki_file_regexp}/; @@@ -153,13 -152,13 +153,13 @@@ if ($form->submitted eq "Cancel") { if ($form->field("do") eq "create" && defined $from) { - redirect($q, "$config{url}/".htmlpage($from)); + redirect($q, urlto($from, undef, 1)); } elsif ($form->field("do") eq "create") { redirect($q, $config{url}); } else { - redirect($q, "$config{url}/".htmlpage($page)); + redirect($q, urlto($page, undef, 1)); } exit; } @@@ -250,7 -249,7 +250,7 @@@ @page_locs=$page; } else { - redirect($q, "$config{url}/".htmlpage($page)); + redirect($q, urlto($page, undef, 1)); exit; } } @@@ -418,7 -417,7 +418,7 @@@ else { # The trailing question mark tries to avoid broken # caches and get the most recent version of the page. - redirect($q, "$config{url}/".htmlpage($page)."?updated"); + redirect($q, urlto($page, undef, 1)."?updated"); } } diff --combined IkiWiki/Plugin/recentchanges.pm index 563ab7db1,dbb9065d4..bef0e7085 --- a/IkiWiki/Plugin/recentchanges.pm +++ b/IkiWiki/Plugin/recentchanges.pm @@@ -4,7 -4,6 +4,7 @@@ package IkiWiki::Plugin::recentchanges use warnings; use strict; use IkiWiki 2.00; +use Encode; sub import { #{{{ hook(type => "getsetup", id => "recentchanges", call => \&getsetup); @@@ -87,7 -86,7 +87,7 @@@ sub cgi ($) { #{{ # page they link to is deleted, or newly created, or # changes for whatever reason. So this CGI handles that # dynamic linking stuff. - my $page=$cgi->param("page"); + my $page=decode_utf8($cgi->param("page")); if (!defined $page) { error("missing page parameter"); } @@@ -104,12 -103,7 +104,7 @@@ "

"); } else { - if (defined pagetype($link)) { - IkiWiki::redirect($cgi, $config{url}.IkiWiki::beautify_urlpath("/".htmlpage($link))); - } - else { - IkiWiki::redirect($cgi, $config{url}.IkiWiki::beautify_urlpath("/".$link)); - } + IkiWiki::redirect($cgi, urlto($link, undef, 1)); } exit; diff --combined IkiWiki/Plugin/remove.pm index 869d32f93,b1cb6233d..772be07b5 --- a/IkiWiki/Plugin/remove.pm +++ b/IkiWiki/Plugin/remove.pm @@@ -21,10 -21,11 +21,10 @@@ sub getsetup () { #{{ }, } #}}} -sub check_canremove ($$$$) { #{{{ +sub check_canremove ($$$) { #{{{ my $page=shift; my $q=shift; my $session=shift; - my $attachment=shift; # Must be a known source file. if (! exists $pagesources{$page}) { @@@ -44,15 -45,11 +44,15 @@@ # Must be editiable. IkiWiki::check_canedit($page, $q, $session); - # This is sorta overkill, but better safe - # than sorry. If a user can't upload an - # attachment, don't let them delete it. - if ($attachment) { - IkiWiki::Plugin::attachment::check_canattach($session, $page, $file); + # If a user can't upload an attachment, don't let them delete it. + # This is sorta overkill, but better safe than sorry. + if (! defined IkiWiki::pagetype($pagesources{$page})) { + if (IkiWiki::Plugin::attachment->can("check_canattach")) { + IkiWiki::Plugin::attachment::check_canattach($session, $page, $file); + } + else { + error("renaming of attachments is not allowed"); + } } } #}}} @@@ -97,7 -94,7 +97,7 @@@ sub removal_confirm ($$@) { #{{ my $attachment=shift; my @pages=@_; - check_canremove($_, $q, $session, $attachment) foreach @pages; + check_canremove($_, $q, $session) foreach @pages; # Save current form state to allow returning to it later # without losing any edits. @@@ -170,7 -167,7 +170,7 @@@ sub sessioncgi ($$) { #{{ # and that the user is allowed to edit(/remove) it. my @files; foreach my $page (@pages) { - check_canremove($page, $q, $session, $q->param("attachment")); + check_canremove($page, $q, $session); # This untaint is safe because of the # checks performed above, which verify the @@@ -210,7 -207,7 +210,7 @@@ if (! exists $pagesources{$parent}) { $parent="index"; } - IkiWiki::redirect($q, $config{url}."/".htmlpage($parent)); + IkiWiki::redirect($q, urlto($parent, '/', 1)); } } else {