summaryrefslogtreecommitdiff
path: root/IkiWiki/Plugin
diff options
context:
space:
mode:
authorJoey Hess <joey@kitenet.net>2007-12-08 19:39:32 -0500
committerJoey Hess <joey@kitenet.net>2007-12-08 19:39:32 -0500
commit5959a32f9746aa600fd852f6b11f635ad2020253 (patch)
tree60f7f26ff1110cc7996aa6a04846949082b93779 /IkiWiki/Plugin
parenta829e5b8650743aac227331db657ba1e87737426 (diff)
real redir cycle detection
Diffstat (limited to 'IkiWiki/Plugin')
-rw-r--r--IkiWiki/Plugin/meta.pm19
1 files changed, 14 insertions, 5 deletions
diff --git a/IkiWiki/Plugin/meta.pm b/IkiWiki/Plugin/meta.pm
index 968e6ccee..4aa545a93 100644
--- a/IkiWiki/Plugin/meta.pm
+++ b/IkiWiki/Plugin/meta.pm
@@ -71,6 +71,7 @@ sub preprocess (@) { #{{{
}
}
elsif ($key eq 'redir') {
+ return "" if $destpage ne $page;
my $safe=0;
if ($value !~ /^\w+:\/\//) {
add_depends($page, $value);
@@ -78,13 +79,21 @@ sub preprocess (@) { #{{{
if (! length $link) {
return "[[meta ".gettext("redir page not found")."]]";
}
+
+ $value=urlto($link, $page);
+ $safe=1;
+
+ # redir cycle detection
$pagestate{$page}{meta}{redir}=$link;
- if ($pagestate{$link}{meta}{redir}) {
- # TODO: real cycle detection
- return "[[meta ".gettext("redir not allowed to point to a page that contains a redir")."]]";
+ my $at=$page;
+ my %seen;
+ while (exists $pagestate{$at}{meta}{redir}) {
+ if ($seen{$at}) {
+ return "[[meta ".gettext("redir cycle is not allowed")."]]";
+ }
+ $seen{$at}=1;
+ $at=$pagestate{$at}{meta}{redir};
}
- $value=urlto($link, $destpage);
- $safe=1;
}
else {
$value=encode_entities($value);