From: Joey Hess Date: Wed, 27 Jan 2010 03:26:50 +0000 (-0500) Subject: template: Preprocess parameters before htmlizing. X-Git-Url: https://sipb.mit.edu/gitweb.cgi/ikiwiki.git/commitdiff_plain/73253d6925ef84f9dd9e72919f8a136b93a0d277 template: Preprocess parameters before htmlizing. Consider a template like: [[!template type=note text=""" [[!inline pages="*foo*"]] """]] The text parameter is htmlized before being passed into the template (in case the template wraps it in a that prevents markdown from htmlizing it later). But, when markdown sees "*foo*", it turns that into foo. Later, when preprocessing the inline directive, that leads to suprising results. To fix this, I made template parameters be preprocessed (and filtered) before being htmlized. Note that I left in the preprocessing (and filtering) of the template output at the end. That's still relevant when the template itself contains preprocessor directives. --- diff --git a/IkiWiki/Plugin/template.pm b/IkiWiki/Plugin/template.pm index b6097bb49..39d9667f9 100644 --- a/IkiWiki/Plugin/template.pm +++ b/IkiWiki/Plugin/template.pm @@ -25,6 +25,10 @@ sub getsetup () { sub preprocess (@) { my %params=@_; + # This needs to run even in scan mode, in order to process + # links and other metadata included via the template. + my $scan=! defined wantarray; + if (! exists $params{id}) { error gettext("missing id parameter") } @@ -58,24 +62,23 @@ sub preprocess (@) { $params{basename}=IkiWiki::basename($params{page}); foreach my $param (keys %params) { + my $value=IkiWiki::preprocess($params{page}, $params{destpage}, + IkiWiki::filter($params{page}, $params{destpagea}, + $params{$param}), $scan); if ($template->query(name => $param)) { $template->param($param => IkiWiki::htmlize($params{page}, $params{destpage}, pagetype($pagesources{$params{page}}), - $params{$param})); + $value)); } if ($template->query(name => "raw_$param")) { - $template->param("raw_$param" => $params{$param}); + $template->param("raw_$param" => $value); } } - # This needs to run even in scan mode, in order to process - # links and other metadata includes via the template. - my $scan=! defined wantarray; - return IkiWiki::preprocess($params{page}, $params{destpage}, - IkiWiki::filter($params{page}, $params{destpage}, - $template->output), $scan); + IkiWiki::filter($params{page}, $params{destpage}, + $template->output), $scan); } 1 diff --git a/debian/changelog b/debian/changelog index 4e76b1d69..0ec696d3c 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +ikiwiki (3.20100123) UNRELEASED; urgency=low + + * template: Preprocess parameters before htmlizing. + + -- Joey Hess Tue, 26 Jan 2010 22:25:33 -0500 + ikiwiki (3.20100122) unstable; urgency=low * inline: Avoid showing edit links if page editing is disabled.