Set it to true every time IkiWiki::filter is called on a full page's content.
This is a much nicer solution, for the po plugin, than previous whitelisting
using caller().
return $content;
}
-sub filter ($$$) {
+sub filter ($$$;$) {
my $page=shift;
my $destpage=shift;
my $content=shift;
+ my $fullpage=shift;
+ $fullpage = 0 unless defined $fullpage;
run_hooks(filter => sub {
$content=shift->(page => $page, destpage => $destpage,
- content => $content);
+ content => $content, fullpage => $fullpage);
});
return $content;
my $preview=htmlize($page, $page, $type,
linkify($page, $page,
preprocess($page, $page,
- filter($page, $page, $content), 0, 1)));
+ filter($page, $page, $content, 'fullpage'), 0, 1)));
run_hooks(format => sub {
$preview=shift->(
page => $page,
linkify($page, $params{destpage},
preprocess($page, $params{destpage},
filter($page, $params{destpage},
- readfile(srcfile($file)))));
+ readfile(srcfile($file)), 'fullpage')));
}
else {
$ret.="\n".
linkify($page, $destpage,
preprocess($page, $destpage,
filter($page, $destpage,
- readfile(srcfile($file))))));
+ readfile(srcfile($file)), 'fullpage'))));
$nested--;
if (isinternal($page)) {
# make inlined text of internal pages searchable
my $page = $params{page};
my $destpage = $params{destpage};
my $content = $params{content};
+ my $fullpage = $params{fullpage};
- my @caller = caller(4);
- # FIXME: need to whitelist inline as well?
- unless ($caller[3] eq "IkiWiki::render" ||
- $caller[3] eq 'IkiWiki::Plugin::sidebar::sidebar_content') {
+ unless ($fullpage) {
return $content;
}
return IkiWiki::htmlize($sidebar_page, $page, $sidebar_type,
IkiWiki::linkify($sidebar_page, $page,
IkiWiki::preprocess($sidebar_page, $page,
- IkiWiki::filter($sidebar_page, $page, $content))));
+ IkiWiki::filter($sidebar_page, $page, $content, 'fullpage'))));
}
}
linkify($page, $page,
preprocess($page, $page,
filter($page, $page,
- readfile($srcfile)))));
+ readfile($srcfile), 'fullpage'))));
my $output=htmlpage($page);
writefile($output, $config{destdir}, genpage($page, $content));
my $content=readfile($srcfile);
my $page=pagename($file);
$pagesources{$page}=$file;
- $content=filter($page, $page, $content);
+ $content=filter($page, $page, $content, 'fullpage');
$content=preprocess($page, $page, $content);
$content=linkify($page, $page, $content);
$content=htmlize($page, $page, $type, $content);
Runs on the raw source of a page, before anything else touches it, and can
make arbitrary changes. The function is passed named parameters "page",
-"destpage", and "content". It should return the filtered content.
+"destpage", "content" and "fullpage". "fullpage" is a true value if,
+and only if, a full page's content is being filtered, e.g. as opposed
+to a directive parameter. It should return the filtered content.
### preprocess