aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--IkiWiki.pm4
-rw-r--r--IkiWiki/CGI.pm2
-rw-r--r--IkiWiki/Plugin/inline.pm2
-rw-r--r--IkiWiki/Plugin/meta.pm2
-rw-r--r--IkiWiki/Plugin/search.pm4
-rw-r--r--IkiWiki/Plugin/sidebar.pm2
-rw-r--r--IkiWiki/Plugin/table.pm2
-rw-r--r--IkiWiki/Plugin/template.pm2
-rw-r--r--IkiWiki/Render.pm4
-rw-r--r--debian/changelog1
-rw-r--r--doc/plugins/search.mdwn8
-rw-r--r--doc/plugins/write.mdwn4
-rw-r--r--po/ikiwiki.pot4
-rwxr-xr-xt/crazy-badass-perl-bug.t4
-rwxr-xr-xt/htmlize.t16
15 files changed, 31 insertions, 30 deletions
diff --git a/IkiWiki.pm b/IkiWiki.pm
index 3f92bda06..a9debfb7d 100644
--- a/IkiWiki.pm
+++ b/IkiWiki.pm
@@ -641,8 +641,9 @@ sub userlink ($) { #{{{
}
} #}}}
-sub htmlize ($$$) { #{{{
+sub htmlize ($$$$) { #{{{
my $page=shift;
+ my $destpage=shift;
my $type=shift;
my $content=shift;
@@ -661,6 +662,7 @@ sub htmlize ($$$) { #{{{
run_hooks(sanitize => sub {
$content=shift->(
page => $page,
+ destpage => $destpage,
content => $content,
);
});
diff --git a/IkiWiki/CGI.pm b/IkiWiki/CGI.pm
index 532f9c5f6..8a294e887 100644
--- a/IkiWiki/CGI.pm
+++ b/IkiWiki/CGI.pm
@@ -397,7 +397,7 @@ sub cgi_editpage ($$) { #{{{
);
});
$form->tmpl_param("page_preview",
- htmlize($page, $type,
+ htmlize($page, $page, $type,
linkify($page, $page,
preprocess($page, $page,
filter($page, $page, $content), 0, 1))));
diff --git a/IkiWiki/Plugin/inline.pm b/IkiWiki/Plugin/inline.pm
index 7d81e9182..344620ebe 100644
--- a/IkiWiki/Plugin/inline.pm
+++ b/IkiWiki/Plugin/inline.pm
@@ -352,7 +352,7 @@ sub get_inline_content ($$) { #{{{
my $type=pagetype($file);
if (defined $type) {
$nested++;
- my $ret=htmlize($page, $type,
+ my $ret=htmlize($page, $destpage, $type,
linkify($page, $destpage,
preprocess($page, $destpage,
filter($page, $destpage,
diff --git a/IkiWiki/Plugin/meta.pm b/IkiWiki/Plugin/meta.pm
index 0afe1c362..e2914a78a 100644
--- a/IkiWiki/Plugin/meta.pm
+++ b/IkiWiki/Plugin/meta.pm
@@ -53,7 +53,7 @@ sub htmlize ($$$) { #{{{
my $page = shift;
my $destpage = shift;
- return IkiWiki::htmlize($page, pagetype($pagesources{$page}),
+ return IkiWiki::htmlize($page, $destpage, pagetype($pagesources{$page}),
IkiWiki::linkify($page, $destpage,
IkiWiki::preprocess($page, $destpage, shift)));
}
diff --git a/IkiWiki/Plugin/search.pm b/IkiWiki/Plugin/search.pm
index 3dc70f0b7..aa0a8085e 100644
--- a/IkiWiki/Plugin/search.pm
+++ b/IkiWiki/Plugin/search.pm
@@ -57,7 +57,7 @@ my $scrubber;
sub index (@) { #{{{
my %params=@_;
- return $params{content} if %IkiWiki::preprocessing;
+ return $params{content} if $IkiWiki::preprocessing{$params{destpage}};
my $db=xapiandb();
my $doc=Search::Xapian::Document->new();
@@ -70,7 +70,7 @@ sub index (@) { #{{{
$title=IkiWiki::pagetitle($params{page});
}
- # Remove any html from text to be indexed.
+ # Remove html from text to be indexed.
if (! defined $scrubber) {
eval q{use HTML::Scrubber};
if (! $@) {
diff --git a/IkiWiki/Plugin/sidebar.pm b/IkiWiki/Plugin/sidebar.pm
index a49726768..7c2e6e1f6 100644
--- a/IkiWiki/Plugin/sidebar.pm
+++ b/IkiWiki/Plugin/sidebar.pm
@@ -27,7 +27,7 @@ sub sidebar_content ($) { #{{{
my $content=readfile(srcfile($sidebar_file));
return unless length $content;
- return IkiWiki::htmlize($page, $sidebar_type,
+ return IkiWiki::htmlize($sidebar_page, $page, $sidebar_type,
IkiWiki::linkify($sidebar_page, $page,
IkiWiki::preprocess($sidebar_page, $page,
IkiWiki::filter($sidebar_page, $page, $content))));
diff --git a/IkiWiki/Plugin/table.pm b/IkiWiki/Plugin/table.pm
index 20c71e1c7..11474c8f0 100644
--- a/IkiWiki/Plugin/table.pm
+++ b/IkiWiki/Plugin/table.pm
@@ -175,7 +175,7 @@ sub htmlize ($$$) { #{{{
my $page = shift;
my $destpage = shift;
- return IkiWiki::htmlize($page, pagetype($pagesources{$page}),
+ return IkiWiki::htmlize($page, $destpage, pagetype($pagesources{$page}),
IkiWiki::preprocess($page, $destpage, shift));
}
diff --git a/IkiWiki/Plugin/template.pm b/IkiWiki/Plugin/template.pm
index 416762fe1..a6e34fcc9 100644
--- a/IkiWiki/Plugin/template.pm
+++ b/IkiWiki/Plugin/template.pm
@@ -48,7 +48,7 @@ sub preprocess (@) { #{{{
foreach my $param (keys %params) {
if ($template->query(name => $param)) {
$template->param($param =>
- IkiWiki::htmlize($params{page},
+ IkiWiki::htmlize($params{page}, $params{destpage},
pagetype($pagesources{$params{page}}),
$params{$param}));
}
diff --git a/IkiWiki/Render.pm b/IkiWiki/Render.pm
index 3422024d1..272eb239a 100644
--- a/IkiWiki/Render.pm
+++ b/IkiWiki/Render.pm
@@ -191,7 +191,7 @@ sub render ($) { #{{{
will_render($page, htmlpage($page), 1);
return if $type=~/^_/;
- my $content=htmlize($page, $type,
+ my $content=htmlize($page, $page, $type,
linkify($page, $page,
preprocess($page, $page,
filter($page, $page,
@@ -520,7 +520,7 @@ sub commandline_render () { #{{{
$content=filter($page, $page, $content);
$content=preprocess($page, $page, $content);
$content=linkify($page, $page, $content);
- $content=htmlize($page, $type, $content);
+ $content=htmlize($page, $page, $type, $content);
$pagemtime{$page}=(stat($srcfile))[9];
print genpage($page, $content);
diff --git a/debian/changelog b/debian/changelog
index c667142a2..34112ab26 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -8,6 +8,7 @@ ikiwiki (2.49) UNRELEASED; urgency=low
* Filter hooks are no longer called during the scan phase. This will
prevent wikilinks added by filters from being scanned properly. But
no known filter hook does that, so let's not waste time on it.
+ * Pass a destpage parameter to the sanitize hook.
-- Joey Hess <joeyh@debian.org> Fri, 30 May 2008 19:08:54 -0400
diff --git a/doc/plugins/search.mdwn b/doc/plugins/search.mdwn
index 67e3b85ef..e53c28c7c 100644
--- a/doc/plugins/search.mdwn
+++ b/doc/plugins/search.mdwn
@@ -7,11 +7,9 @@ This plugin adds full text search to ikiwiki, using the
and the [[cpan Search::Xapian]] perl module. (The [[cpan HTML::Scrubber]]
perl module will also be used, if available.)
-Ikiwiki will handle indexing new and changed page contents. Note that it
-indexes page contents before they are preprocessed and converted to html,
-as this tends to produce less noisy search results. Also, since it only
-indexes page contents, files copied by the [[rawhtml]] plugin will not be
-indexed, nor will other types of data files.
+Ikiwiki will handle indexing new and changed page contents. Note that since
+it only indexes page contents, files copied by the [[rawhtml]] plugin will
+not be indexed, nor will other types of data files.
There is one setting you may need to use in the config file. `omega_cgi`
should point to the location of the omega cgi program. The default location
diff --git a/doc/plugins/write.mdwn b/doc/plugins/write.mdwn
index 606031cf2..35f391f7f 100644
--- a/doc/plugins/write.mdwn
+++ b/doc/plugins/write.mdwn
@@ -211,8 +211,8 @@ want to change the default ("page.tmpl"). Template files are looked for in
Use this to implement html sanitization or anything else that needs to
modify the body of a page after it has been fully converted to html.
-The function is passed named parameters: "page" and "content", and
-should return the sanitized content.
+The function is passed named parameters: "page", "destpage", and "content",
+and should return the sanitized content.
### format
diff --git a/po/ikiwiki.pot b/po/ikiwiki.pot
index 9d791153f..f65f42212 100644
--- a/po/ikiwiki.pot
+++ b/po/ikiwiki.pot
@@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2008-06-04 00:52-0400\n"
+"POT-Creation-Date: 2008-06-04 01:17-0400\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
@@ -707,7 +707,7 @@ msgstr ""
#. translators: preprocessor directive name,
#. translators: the second a page name, the
#. translators: third a number.
-#: ../IkiWiki.pm:761
+#: ../IkiWiki.pm:763
#, perl-format
msgid "%s preprocessing loop detected on %s at depth %i"
msgstr ""
diff --git a/t/crazy-badass-perl-bug.t b/t/crazy-badass-perl-bug.t
index 27812559b..80724d174 100755
--- a/t/crazy-badass-perl-bug.t
+++ b/t/crazy-badass-perl-bug.t
@@ -13,6 +13,6 @@ BEGIN { use_ok("IkiWiki"); }
%config=IkiWiki::defaultconfig();
$config{srcdir}=$config{destdir}="/dev/null";
IkiWiki::loadplugins(); IkiWiki::checkconfig();
-ok(IkiWiki::htmlize("foo", "mdwn", readfile("t/test1.mdwn")));
-ok(IkiWiki::htmlize("foo", "mdwn", readfile("t/test3.mdwn")),
+ok(IkiWiki::htmlize("foo", "foo", "mdwn", readfile("t/test1.mdwn")));
+ok(IkiWiki::htmlize("foo", "foo", "mdwn", readfile("t/test3.mdwn")),
"wtf?") for 1..100;
diff --git a/t/htmlize.t b/t/htmlize.t
index b19dbcf68..a7e7f8c39 100755
--- a/t/htmlize.t
+++ b/t/htmlize.t
@@ -12,16 +12,16 @@ $config{srcdir}=$config{destdir}="/dev/null";
IkiWiki::loadplugins();
IkiWiki::checkconfig();
-is(IkiWiki::htmlize("foo", "mdwn", "foo\n\nbar\n"), "<p>foo</p>\n\n<p>bar</p>\n",
+is(IkiWiki::htmlize("foo", "foo", "mdwn", "foo\n\nbar\n"), "<p>foo</p>\n\n<p>bar</p>\n",
"basic");
-is(IkiWiki::htmlize("foo", "mdwn", readfile("t/test1.mdwn")),
+is(IkiWiki::htmlize("foo", "foo", "mdwn", readfile("t/test1.mdwn")),
Encode::decode_utf8(qq{<p><img src="../images/o.jpg" alt="o" title="&oacute;" />\nóóóóó</p>\n}),
"utf8; bug #373203");
-ok(IkiWiki::htmlize("foo", "mdwn", readfile("t/test2.mdwn")),
+ok(IkiWiki::htmlize("foo", "foo", "mdwn", readfile("t/test2.mdwn")),
"this file crashes markdown if it's fed in as decoded utf-8");
sub gotcha {
- my $html=IkiWiki::htmlize("foo", "mdwn", shift);
+ my $html=IkiWiki::htmlize("foo", "foo", "mdwn", shift);
return $html =~ /GOTCHA/;
}
ok(!gotcha(q{<a href="javascript:alert('GOTCHA')">click me</a>}),
@@ -56,15 +56,15 @@ ok(gotcha(q{<p>javascript:alert('GOTCHA')</p>}),
be perverse and assume it is?)");
ok(gotcha(q{<img src="javascript.png?GOTCHA">}), "not javascript");
ok(gotcha(q{<a href="javascript.png?GOTCHA">foo</a>}), "not javascript");
-is(IkiWiki::htmlize("foo", "mdwn",
+is(IkiWiki::htmlize("foo", "foo", "mdwn",
q{<img alt="foo" src="foo.gif">}),
q{<img alt="foo" src="foo.gif">}, "img with alt tag allowed");
-is(IkiWiki::htmlize("foo", "mdwn",
+is(IkiWiki::htmlize("foo", "foo", "mdwn",
q{<a href="http://google.com/">}),
q{<a href="http://google.com/">}, "absolute url allowed");
-is(IkiWiki::htmlize("foo", "mdwn",
+is(IkiWiki::htmlize("foo", "foo", "mdwn",
q{<a href="foo.html">}),
q{<a href="foo.html">}, "relative url allowed");
-is(IkiWiki::htmlize("foo", "mdwn",
+is(IkiWiki::htmlize("foo", "foo", "mdwn",
q{<span class="foo">bar</span>}),
q{<span class="foo">bar</span>}, "class attribute allowed");