aboutsummaryrefslogtreecommitdiff
path: root/IkiWiki/Plugin/inline.pm
diff options
context:
space:
mode:
authorJoey Hess <joey@kodama.kitenet.net>2008-12-11 15:01:26 -0500
committerJoey Hess <joey@kodama.kitenet.net>2008-12-11 15:01:26 -0500
commitb67632cdcdd333cf0a88d03c0f7e6e62921f32c3 (patch)
treecaa351c9a90288cbc3cef536fda40b6f4e7a5922 /IkiWiki/Plugin/inline.pm
parent2cd7eecf896261834bcd66d8ec3a9fd3bb7236d8 (diff)
downloadikiwiki-b67632cdcdd333cf0a88d03c0f7e6e62921f32c3.tar
ikiwiki-b67632cdcdd333cf0a88d03c0f7e6e62921f32c3.tar.gz
inline: Support feedfile option to change the filename of the feed generated.
Diffstat (limited to 'IkiWiki/Plugin/inline.pm')
-rw-r--r--IkiWiki/Plugin/inline.pm63
1 files changed, 36 insertions, 27 deletions
diff --git a/IkiWiki/Plugin/inline.pm b/IkiWiki/Plugin/inline.pm
index 5e4df95f4..17cc46e0e 100644
--- a/IkiWiki/Plugin/inline.pm
+++ b/IkiWiki/Plugin/inline.pm
@@ -26,8 +26,7 @@ sub import { #{{{
# Hook to change to do pinging since it's called late.
# This ensures each page only pings once and prevents slow
# pings interrupting page builds.
- hook(type => "change", id => "inline",
- call => \&IkiWiki::pingurl);
+ hook(type => "change", id => "inline", call => \&IkiWiki::pingurl);
} # }}}
sub getopt () { #{{{
@@ -238,28 +237,46 @@ sub preprocess_inline (@) { #{{{
@feedlist=grep { pagespec_match($_, $params{feedpages}, location => $params{page}) } @feedlist;
}
- my $feednum="";
-
- my $feedid=join("\0", map { $_."\0".$params{$_} } sort keys %params);
- if (exists $knownfeeds{$feedid}) {
- $feednum=$knownfeeds{$feedid};
- }
- else {
- if (exists $page_numfeeds{$params{destpage}}) {
- if ($feeds) {
- $feednum=$knownfeeds{$feedid}=++$page_numfeeds{$params{destpage}};
+ my ($feedbase, $feednum);
+ if ($feeds) {
+ # Ensure that multiple feeds on a page go to unique files.
+
+ # Feedfile can lead to conflicts if usedirs is not enabled,
+ # so avoid supporting it in that case.
+ delete $params{feedfile} if ! $config{usedirs};
+ # Tight limits on legal feedfiles, to avoid security issues
+ # and conflicts.
+ if (defined $params{feedfile}) {
+ if ($params{feedfile} =~ /\// ||
+ $params{feedfile} !~ /$config{wiki_file_regexp}/) {
+ error("illegal feedfile");
}
+ $params{feedfile}=possibly_foolish_untaint($params{feedfile});
+ }
+ $feedbase=targetpage($params{destpage}, "", $params{feedfile});
+
+ my $feedid=join("\0", $feedbase, map { $_."\0".$params{$_} } sort keys %params);
+ if (exists $knownfeeds{$feedid}) {
+ $feednum=$knownfeeds{$feedid};
}
else {
- $feednum=$knownfeeds{$feedid}="";
- if ($feeds) {
- $page_numfeeds{$params{destpage}}=1;
+ if (exists $page_numfeeds{$params{destpage}}{$feedbase}) {
+ if ($feeds) {
+ $feednum=$knownfeeds{$feedid}=++$page_numfeeds{$params{destpage}}{$feedbase};
+ }
+ }
+ else {
+ $feednum=$knownfeeds{$feedid}="";
+ if ($feeds) {
+ $page_numfeeds{$params{destpage}}{$feedbase}=1;
+ }
}
}
}
- my $rssurl=basename(rsspage($params{destpage}).$feednum) if $feeds && $rss;
- my $atomurl=basename(atompage($params{destpage}).$feednum) if $feeds && $atom;
+ my $rssurl=basename($feedbase."rss".$feednum) if $feeds && $rss;
+ my $atomurl=basename($feedbase."atom".$feednum) if $feeds && $atom;
+
my $ret="";
if (length $config{cgiurl} && ! $params{preview} && (exists $params{rootpage} ||
@@ -375,7 +392,7 @@ sub preprocess_inline (@) { #{{{
if ($feeds && ! (! $emptyfeeds && ! @feedlist)) {
if ($rss) {
- my $rssp=rsspage($params{destpage}).$feednum;
+ my $rssp=$feedbase."rss".$feednum;
will_render($params{destpage}, $rssp);
if (! $params{preview}) {
writefile($rssp, $config{destdir},
@@ -386,7 +403,7 @@ sub preprocess_inline (@) { #{{{
}
}
if ($atom) {
- my $atomp=atompage($params{destpage}).$feednum;
+ my $atomp=$feedbase."atom".$feednum;
will_render($params{destpage}, $atomp);
if (! $params{preview}) {
writefile($atomp, $config{destdir},
@@ -475,14 +492,6 @@ sub absolute_urls ($$) { #{{{
return $content;
} #}}}
-sub rsspage ($) { #{{{
- return targetpage(shift, "rss");
-} #}}}
-
-sub atompage ($) { #{{{
- return targetpage(shift, "atom");
-} #}}}
-
sub genfeed ($$$$$@) { #{{{
my $feedtype=shift;
my $feedurl=shift;