]> sipb.mit.edu Git - ikiwiki.git/blob - doc/bugs/Can__39__t_create_root_page.mdwn
Merge branch 'master'
[ikiwiki.git] / doc / bugs / Can__39__t_create_root_page.mdwn
1 This is a link to a non-existent page in the root directory: [[/root_page_test]] (\[[/root\_page\_test]])
2
3 When you click on the question mark to create the page, you get *Error: bad page name*.  It's a valid [[wikilink]], shouldn't it create the page? --[[sabr]]
4
5 > Is it a valid wikilink?  Should Iki prevent the page from being created? --[[sabr]], 2 months later
6
7 This type of page name (with leading slash) also gets created by the aggregate plugin: /cgi-bin/ikiwiki.cgi?page=%2FCalculated_Risk&from=news%2FAll_Stories&do=create  I'm now pretty convinced that Iki should handle this without error.  I'll investigate if I can find the time.
8
9 > As documented on [[ikiwiki/subpage/linkingrules]], such an absolute
10 > link works perfectly when the linked page already exists.
11 >
12 > The CGI behaviour is thus not consistent with the general linking
13 > rules, which is annoying for me : I'm using templates to generate
14 > links to pages that may not exist yet, and I would like the "right"
15 > path to be selected by default, instead of the usual
16 > <current>/subdir/subpage, when a user clicks the "?" link to create
17 > the missing page ; that's why I'm using absolute paths.
18 >
19 >> Totally agree, this had only not been addressed due to lack of time on
20 >> my part. (I have about 50 ikiwiki things on my todo list.) --[[Joey]]
21 >
22 > Anyway, having the CGI consider invalid an otherwise valid wikilink
23 > seems a bit weird to me, so I had a look to the code, and here is a
24 > patch that should fix this issue ; I proceeded the only way I could
25 > find to prevent side-effects : the only place where I use `$origpage`
26 > is a match, so no function at all is fed with a `$page` with 
27 > leading slash :
28 >
29 > -- intrigeri
30
31
32         diff --git a/IkiWiki/CGI.pm b/IkiWiki/CGI.pm
33         index 99cead6..23d9616 100644
34         --- a/IkiWiki/CGI.pm
35         +++ b/IkiWiki/CGI.pm
36         @@ -305,9 +305,11 @@ sub cgi_editpage ($$) {
37                 my $page=$form->field('page');
38                 $page=possibly_foolish_untaint($page);
39                 if (! defined $page || ! length $page ||
40         -           file_pruned($page, $config{srcdir}) || $page=~/^\//) {
41         +           file_pruned($page, $config{srcdir})) {
42                         error("bad page name");
43                 }
44         +       my $origpage=$page;
45         +       $page =~ s#^/##;
46          
47                 my $baseurl=$config{url}."/".htmlpage($page);
48                 
49         @@ -425,6 +427,7 @@ sub cgi_editpage ($$) {
50                                     $from ne $form->field('from') ||
51                                     file_pruned($from, $config{srcdir}) ||
52                                     $from=~/^\// ||
53         +                           $origpage=~/^\// ||
54                                     $form->submitted eq "Preview") {
55                                         @page_locs=$best_loc=$page;
56                                 }
57
58
59 > [[Applied|done]]. BTW, I also accept full git changesets, if you like
60 > having your name in commit logs. :-)
61
62 >> Thanks. I'm considering setting up a public Git repository with topic branches, so that :
63
64 >> - I can simply ask you to pull from there, next time
65 >> - I have a tool to go on learning the beast (i.e. Git)
66
67 >> -- intrigeri
68
69 [[!tag patch]]