]> git.vanrenterghem.biz Git - git.ikiwiki.info.git/blob - doc/patchqueue/pruning_is_too_strict.mdwn
more
[git.ikiwiki.info.git] / doc / patchqueue / pruning_is_too_strict.mdwn
1 Preliminary patch for a feature wishlist item: [[bugs/pruning_is_too_strict]].
3     diff -ur ikiwiki-orig/IkiWiki/CGI.pm ikiwiki/IkiWiki/CGI.pm
4     --- ikiwiki-orig/IkiWiki/CGI.pm     2006-10-27 20:15:17.000000000 -0700
5     +++ ikiwiki/IkiWiki/CGI.pm  2006-11-07 22:32:41.000000000 -0800
6     @@ -405,7 +405,7 @@
7         my ($page)=$form->field('page');
8         $page=titlepage(possibly_foolish_untaint($page));
9         if (! defined $page || ! length $page ||
10     -       $page=~/$config{wiki_file_prune_regexp}/ || $page=~/^\//) {
11     +       is_prune($page) || $page=~/^\//) {
12                 error("bad page name");
13         }
15     @@ -495,8 +495,7 @@
16                         my $best_loc;
17                         if (! defined $from || ! length $from ||
18                             $from ne $form->field('from') ||
19     -                       $from=~/$config{wiki_file_prune_regexp}/ ||
20     -                       $from=~/^\// ||
21     +                       is_prune($from) || $from=~/^\// ||
22                             $form->submitted eq "Preview") {
23                                 @page_locs=$best_loc=$page;
24                         }
25     diff -ur ikiwiki-orig/IkiWiki/Render.pm ikiwiki/IkiWiki/Render.pm
26     --- ikiwiki-orig/IkiWiki/Render.pm  2006-10-27 20:15:17.000000000 -0700
27     +++ ikiwiki/IkiWiki/Render.pm       2006-11-07 22:36:48.000000000 -0800
28     @@ -189,7 +193,7 @@
29                 no_chdir => 1,
30                 wanted => sub {
31                         $_=decode_utf8($_);
32     -                   if (/$config{wiki_file_prune_regexp}/) {
33     +                   if (is_prune($_)) {
34                                 $File::Find::prune=1;
35                         }
36                         elsif (! -d $_ && ! -l $_) {
37     @@ -209,7 +213,7 @@
38                 no_chdir => 1,
39                 wanted => sub {
40                         $_=decode_utf8($_);
41     -                   if (/$config{wiki_file_prune_regexp}/) {
42     +                   if (is_prune($_, $config{underlaydir})) {
43                                 $File::Find::prune=1;
44                         }
45                         elsif (! -d $_ && ! -l $_) {
46     diff -ur ikiwiki-orig/IkiWiki.pm ikiwiki/IkiWiki.pm
47     --- ikiwiki-orig/IkiWiki.pm 2006-10-27 20:15:23.000000000 -0700
48     +++ ikiwiki/IkiWiki.pm      2006-11-07 22:21:17.000000000 -0800
49     @@ -21,6 +21,8 @@
50      # Optimisation.
51      use Memoize;
52      memoize("abs2rel");
53     +memoize("basefile");
54     +memoize("is_prune");
55      memoize("pagespec_translate");
57      my $installdir=''; # INSTALLDIR_AUTOREPLACE done by Makefile, DNE
58     @@ -343,6 +352,22 @@
59         return $page;
60      } #}}}
62     +sub basefile ($;$) { #{{{
63     +   my $file=shift;
64     +   my $base=shift || $config{srcdir};
65     +
66     +   require File::Spec;
67     +   $base=File::Spec->canonpath($base);
68     +   my $ret=File::Spec->canonpath($file);
69     +
70     +   $ret=~s#^$base/*##;
71     +   return $ret;
72     +} #}}}
73     +
74     +sub is_prune ($;$) { #{{{
75     +   return basefile($_[0], $_[1])=~m/$config{wiki_file_prune_regexp}/;
76     +} #}}}
77     +
78      sub abs2rel ($$) { #{{{
79         # Work around very innefficient behavior in File::Spec if abs2rel
80         # is passed two relative paths. It's much faster if paths are