From: Simon McVittie Date: Sun, 26 Jul 2009 15:48:25 +0000 (+0100) Subject: getsource: don't allow getting the source of an attachment X-Git-Url: https://sipb.mit.edu/gitweb.cgi/ikiwiki.git/commitdiff_plain/ea244ab7b53afbd710dab267ca9a8fb9f17cfb00 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). --- diff --git a/IkiWiki/Plugin/getsource.pm b/IkiWiki/Plugin/getsource.pm index 6a208f1e7..1b7eb56c6 100644 --- a/IkiWiki/Plugin/getsource.pm +++ b/IkiWiki/Plugin/getsource.pm @@ -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"), + "

". + sprintf(gettext("%s is an attachment, not a page."), + htmllink("", "", $page)). + "

")); + exit; + } + my $data = IkiWiki::readfile(IkiWiki::srcfile($IkiWiki::pagesources{$page})); if (! $config{getsource_mimetype}) {