diff options
author | Joey Hess <joey@kitenet.net> | 2008-07-10 14:56:52 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2008-07-10 14:56:52 -0400 |
commit | ac4a11ba50b4093bebe32d99c48c0de53ca414d8 (patch) | |
tree | 525a0e41e02435db8121dc7a7df126167229a552 /doc | |
parent | 5d26ded3811cd050a1c70ccf76f3022a787a9588 (diff) |
web commit by intrigeri: added opinion + patch
Diffstat (limited to 'doc')
-rw-r--r-- | doc/bugs/Can__39__t_create_root_page.mdwn | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/doc/bugs/Can__39__t_create_root_page.mdwn b/doc/bugs/Can__39__t_create_root_page.mdwn index 11be2b7b7..b56f3bddc 100644 --- a/doc/bugs/Can__39__t_create_root_page.mdwn +++ b/doc/bugs/Can__39__t_create_root_page.mdwn @@ -5,3 +5,51 @@ When you click on the question mark to create the page, you get *Error: bad page > 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 +> <current>/subdir/subpage, when a user clicks the "?" link to create +> the missing page ; that's why I'm using absolute paths. +> +> 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; + } + +[[tag patch]] |