getsource: don't allow getting the source of an attachment

Serving up images etc. as text/plain; charset=utf-8 is unlikely to work
very well, and there's no point in having this CGI action for attachments
(since they're copied into the output as-is anyway).
master
Simon McVittie 2009-07-26 16:48:25 +01:00
parent 0afcec7346
commit ea244ab7b5
1 changed files with 11 additions and 0 deletions

View File

@ -66,6 +66,17 @@ sub cgi_getsource ($) {
exit;
}
if (! defined pagetype($IkiWiki::pagesources{$page})) {
IkiWiki::cgi_custom_failure(
$cgi->header(-status => "403 Forbidden"),
IkiWiki::misctemplate(gettext("not a page"),
"<p>".
sprintf(gettext("%s is an attachment, not a page."),
htmllink("", "", $page)).
"</p>"));
exit;
}
my $data = IkiWiki::readfile(IkiWiki::srcfile($IkiWiki::pagesources{$page}));
if (! $config{getsource_mimetype}) {