aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoey Hess <joey@kodama.kitenet.net>2008-11-18 02:43:17 -0500
committerJoey Hess <joey@kodama.kitenet.net>2008-11-18 02:43:17 -0500
commit15269fed646bf14692061e634969c98b614daaad (patch)
tree25517c9ef16f3ab3153d405df5971b0515359add
parent767bf9c4838277602b75522275c9f08d122f37a1 (diff)
downloadikiwiki-15269fed646bf14692061e634969c98b614daaad.tar
ikiwiki-15269fed646bf14692061e634969c98b614daaad.tar.gz
improve escaping of wikilinks and preprocessor directives
The old method failed for '[' x 3.
-rw-r--r--IkiWiki/Plugin/aggregate.pm8
-rw-r--r--IkiWiki/Plugin/recentchanges.pm3
-rw-r--r--IkiWiki/Plugin/recentchangesdiff.pm3
-rw-r--r--debian/changelog2
4 files changed, 9 insertions, 7 deletions
diff --git a/IkiWiki/Plugin/aggregate.pm b/IkiWiki/Plugin/aggregate.pm
index f256b3ac1..6cdbbc0e9 100644
--- a/IkiWiki/Plugin/aggregate.pm
+++ b/IkiWiki/Plugin/aggregate.pm
@@ -610,7 +610,7 @@ sub add_page (@) { #{{{
my $template=template($feed->{template}, blind_cache => 1);
$template->param(title => $params{title})
if defined $params{title} && length($params{title});
- $template->param(content => htmlescape(htmlabs($params{content},
+ $template->param(content => wikiescape(htmlabs($params{content},
defined $params{base} ? $params{base} : $feed->{feedurl})));
$template->param(name => $feed->{name});
$template->param(url => $feed->{url});
@@ -637,11 +637,9 @@ sub add_page (@) { #{{{
}
} #}}}
-sub htmlescape ($) { #{{{
+sub wikiescape ($) { #{{{
# escape accidental wikilinks and preprocessor stuff
- my $html=shift;
- $html=~s/(?<!\\)\[\[/\\\[\[/g;
- return $html;
+ return encode_entities(shift, '\[\]');
} #}}}
sub urlabs ($$) { #{{{
diff --git a/IkiWiki/Plugin/recentchanges.pm b/IkiWiki/Plugin/recentchanges.pm
index 3f70664ac..39a123ccf 100644
--- a/IkiWiki/Plugin/recentchanges.pm
+++ b/IkiWiki/Plugin/recentchanges.pm
@@ -5,6 +5,7 @@ use warnings;
use strict;
use IkiWiki 2.00;
use Encode;
+use HTML::Entities;
sub import { #{{{
hook(type => "getsetup", id => "recentchanges", call => \&getsetup);
@@ -163,7 +164,7 @@ sub store ($$$) { #{{{
if (ref $change->{message}) {
foreach my $field (@{$change->{message}}) {
if (exists $field->{line}) {
- $field->{line} =~ s/(?<!\\)\[\[/\\\[\[/g;
+ $field->{line} = encode_entities($field->{line}, '\[\]');
}
}
}
diff --git a/IkiWiki/Plugin/recentchangesdiff.pm b/IkiWiki/Plugin/recentchangesdiff.pm
index 36acef72e..bc793bada 100644
--- a/IkiWiki/Plugin/recentchangesdiff.pm
+++ b/IkiWiki/Plugin/recentchangesdiff.pm
@@ -4,6 +4,7 @@ package IkiWiki::Plugin::recentchangesdiff;
use warnings;
use strict;
use IkiWiki 2.00;
+use HTML::Entities;
my $maxlines=200;
@@ -39,7 +40,7 @@ sub pagetemplate (@) { #{{{
$diff=join("", @lines);
}
# escape links and preprocessor stuff
- $diff =~ s/(?<!\\)\[\[/\\\[\[/g;
+ $diff = encode_entities($diff, '\[\]');
$template->param(diff => $diff);
}
}
diff --git a/debian/changelog b/debian/changelog
index 294cae6dc..eeb9fe6ce 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -3,6 +3,8 @@ ikiwiki (2.71) UNRELEASED; urgency=low
* htmlbalance: New plugin contributed by Simon McVittie.
* Change deb dependencies to list Text::Markdown before markdown (really
this time).
+ * Improve escaping of wikilinks and preprocessor directives in content
+ produced by aggregate and recentchanges.
-- Joey Hess <joeyh@debian.org> Mon, 17 Nov 2008 14:02:10 -0500