]> git.vanrenterghem.biz Git - git.ikiwiki.info.git/commitdiff
Merge commit 'smcv/beautify'
authorJoey Hess <joey@kodama.kitenet.net>
Sat, 27 Sep 2008 17:00:48 +0000 (13:00 -0400)
committerJoey Hess <joey@kodama.kitenet.net>
Sat, 27 Sep 2008 17:00:48 +0000 (13:00 -0400)
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

1  2 
IkiWiki/Plugin/editpage.pm
IkiWiki/Plugin/recentchanges.pm
IkiWiki/Plugin/remove.pm

index 68f43bf16614483e9120fe94f45c84890704a0c2,e0705249709dbe17f62ee102b1e225f182e00f6e..687ebf51e63d4c7daebdcf6bfe172ad90674a8da
@@@ -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}/;
        
        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;
        }
                                        @page_locs=$page;
                                }
                                else {
-                                       redirect($q, "$config{url}/".htmlpage($page));
+                                       redirect($q, urlto($page, undef, 1));
                                        exit;
                                }
                        }
                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");
                }
        }
  
index 563ab7db1950e1d9ca4863d54784a86ca2bd47ea,dbb9065d494c9f14c06cb494d9f5296e1598f122..bef0e7085f4f4bbfe3d7986d21cbb30f29cbbce9
@@@ -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");
                }
                                "</p>");
                }
                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 869d32f9303e41a2e96198615a2171305f6732e6,b1cb6233d297a671328f32b05927b88f95124525..772be07b59f5ea1ff7b931216940fe0bc4dbaa3f
@@@ -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}) {
        # 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
                                if (! exists $pagesources{$parent}) {
                                        $parent="index";
                                }
-                               IkiWiki::redirect($q, $config{url}."/".htmlpage($parent));
+                               IkiWiki::redirect($q, urlto($parent, '/', 1));
                        }
                }
                else {