aboutsummaryrefslogtreecommitdiff
path: root/IkiWiki
diff options
context:
space:
mode:
Diffstat (limited to 'IkiWiki')
-rw-r--r--IkiWiki/CGI.pm14
-rw-r--r--IkiWiki/Plugin/comments.pm10
-rw-r--r--IkiWiki/Plugin/conditional.pm6
-rw-r--r--IkiWiki/Plugin/inline.pm8
-rw-r--r--IkiWiki/Plugin/trail.pm7
5 files changed, 37 insertions, 8 deletions
diff --git a/IkiWiki/CGI.pm b/IkiWiki/CGI.pm
index c0d8f598b..cb83319e6 100644
--- a/IkiWiki/CGI.pm
+++ b/IkiWiki/CGI.pm
@@ -110,11 +110,23 @@ sub decode_cgi_utf8 ($) {
}
}
+sub safe_decode_utf8 ($) {
+ my $octets = shift;
+ # call decode_utf8 on >= 5.20 only if it's not already decoded,
+ # otherwise it balks, on < 5.20, always call it
+ if ($] < 5.02 || !Encode::is_utf8($octets)) {
+ return decode_utf8($octets);
+ }
+ else {
+ return $octets;
+ }
+}
+
sub decode_form_utf8 ($) {
if ($] >= 5.01) {
my $form = shift;
foreach my $f ($form->field) {
- my @value=map { decode_utf8($_) } $form->field($f);
+ my @value=map { safe_decode_utf8($_) } $form->field($f);
$form->field(name => $f,
value => \@value,
force => 1,
diff --git a/IkiWiki/Plugin/comments.pm b/IkiWiki/Plugin/comments.pm
index a0ca9f32e..98ae13810 100644
--- a/IkiWiki/Plugin/comments.pm
+++ b/IkiWiki/Plugin/comments.pm
@@ -438,6 +438,16 @@ sub editcomment ($$) {
$page));
}
+ # There's no UI to get here, but someone might construct the URL,
+ # leading to a comment that exists in the repository but isn't
+ # shown
+ if (!pagespec_match($page, $config{comments_pagespec},
+ location => $page)) {
+ error(sprintf(gettext(
+ "comments on page '%s' are not allowed"),
+ $page));
+ }
+
if (pagespec_match($page, $config{comments_closed_pagespec},
location => $page)) {
error(sprintf(gettext(
diff --git a/IkiWiki/Plugin/conditional.pm b/IkiWiki/Plugin/conditional.pm
index 0a3d7fb4c..b450f1a0a 100644
--- a/IkiWiki/Plugin/conditional.pm
+++ b/IkiWiki/Plugin/conditional.pm
@@ -33,11 +33,15 @@ sub preprocess_if (@) {
# An optimisation to avoid needless looping over every page
# for simple uses of some of the tests.
$params{test} =~ /^([\s\!()]*((enabled|sourcepage|destpage|included)\([^)]*\)|(and|or))[\s\!()]*)+$/) {
- add_depends($params{page}, "($params{test}) and $params{page}");
$result=pagespec_match($params{page}, $params{test},
location => $params{page},
sourcepage => $params{page},
destpage => $params{destpage});
+ my $i = $result->influences;
+ foreach my $k (keys %$i) {
+ # minor optimization: influences are always simple dependencies
+ $IkiWiki::depends_simple{$params{page}}{lc $k} |= $i->{$k};
+ }
}
else {
$result=pagespec_match_list($params{page}, $params{test},
diff --git a/IkiWiki/Plugin/inline.pm b/IkiWiki/Plugin/inline.pm
index 123dfd364..f578526cc 100644
--- a/IkiWiki/Plugin/inline.pm
+++ b/IkiWiki/Plugin/inline.pm
@@ -329,8 +329,12 @@ sub preprocess_inline (@) {
my $ret="";
- if (length $config{cgiurl} && ! $params{preview} && (exists $params{rootpage} ||
- (exists $params{postform} && yesno($params{postform}))) &&
+ my $postform = (exists $params{rootpage});
+ if (exists $params{postform}) {
+ $postform = yesno($params{postform});
+ }
+
+ if (length $config{cgiurl} && ! $params{preview} && $postform &&
IkiWiki->can("cgi_editpage")) {
# Add a blog post form, with feed buttons.
my $formtemplate=template_depends("blogpost.tmpl", $params{page}, blind_cache => 1);
diff --git a/IkiWiki/Plugin/trail.pm b/IkiWiki/Plugin/trail.pm
index d5fb2b5d6..476db4dcb 100644
--- a/IkiWiki/Plugin/trail.pm
+++ b/IkiWiki/Plugin/trail.pm
@@ -319,10 +319,9 @@ sub prerender {
}
if (defined $pagestate{$trail}{trail}{sort}) {
- # re-sort
- @$members = pagespec_match_list($trail, 'internal(*)',
- list => $members,
- sort => $pagestate{$trail}{trail}{sort});
+ @$members = IkiWiki::sort_pages(
+ $pagestate{$trail}{trail}{sort},
+ $members);
}
if (IkiWiki::yesno $pagestate{$trail}{trail}{reverse}) {