X-Git-Url: http://git.vanrenterghem.biz/git.ikiwiki.info.git/blobdiff_plain/143c8770d13698a9fabf9d7ac86a268a286033da..f02672c113813c37a659991ae984a2368e15b8db:/doc/bugs/Can__39__t_create_root_page.mdwn diff --git a/doc/bugs/Can__39__t_create_root_page.mdwn b/doc/bugs/Can__39__t_create_root_page.mdwn index 0ef7e314c..91c2eae60 100644 --- a/doc/bugs/Can__39__t_create_root_page.mdwn +++ b/doc/bugs/Can__39__t_create_root_page.mdwn @@ -1,5 +1,69 @@ This is a link to a non-existent page in the root directory: [[/root_page_test]] (\[[/root\_page\_test]]) -When you click on it to create the page, you get *Error: bad page name*. It's a valid [[wikilink]], shouldn't it create the page? --[[sabr]] +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]] -> 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. +> Is it a valid wikilink? Should Iki prevent the page from being created? --[[sabr]], 2 months later + +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. + +> As documented on [[ikiwiki/subpage/linkingrules]], such an absolute +> link works perfectly when the linked page already exists. +> +> The CGI behaviour is thus not consistent with the general linking +> rules, which is annoying for me : I'm using templates to generate +> links to pages that may not exist yet, and I would like the "right" +> path to be selected by default, instead of the usual +> /subdir/subpage, when a user clicks the "?" link to create +> the missing page ; that's why I'm using absolute paths. +> +>> Totally agree, this had only not been addressed due to lack of time on +>> my part. (I have about 50 ikiwiki things on my todo list.) --[[Joey]] +> +> Anyway, having the CGI consider invalid an otherwise valid wikilink +> seems a bit weird to me, so I had a look to the code, and here is a +> patch that should fix this issue ; I proceeded the only way I could +> find to prevent side-effects : the only place where I use `$origpage` +> is a match, so no function at all is fed with a `$page` with +> leading slash : +> +> -- intrigeri + + + diff --git a/IkiWiki/CGI.pm b/IkiWiki/CGI.pm + index 99cead6..23d9616 100644 + --- a/IkiWiki/CGI.pm + +++ b/IkiWiki/CGI.pm + @@ -305,9 +305,11 @@ sub cgi_editpage ($$) { + my $page=$form->field('page'); + $page=possibly_foolish_untaint($page); + if (! defined $page || ! length $page || + - file_pruned($page, $config{srcdir}) || $page=~/^\//) { + + file_pruned($page, $config{srcdir})) { + error("bad page name"); + } + + my $origpage=$page; + + $page =~ s#^/##; + + my $baseurl=$config{url}."/".htmlpage($page); + + @@ -425,6 +427,7 @@ sub cgi_editpage ($$) { + $from ne $form->field('from') || + file_pruned($from, $config{srcdir}) || + $from=~/^\// || + + $origpage=~/^\// || + $form->submitted eq "Preview") { + @page_locs=$best_loc=$page; + } + + +> [[Applied|done]]. BTW, I also accept full git changesets, if you like +> having your name in commit logs. :-) + +>> Thanks. I'm considering setting up a public Git repository with topic branches, so that : + +>> - I can simply ask you to pull from there, next time +>> - I have a tool to go on learning the beast (i.e. Git) + +>> -- intrigeri + +[[!tag patch]]