From 824cf7db1b96a16b080e284bc3ebf90c1f14a203 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Sat, 1 Dec 2018 21:18:23 +0000 Subject: po: Always filter .po files The input to filter hooks is meant to be the content of a source file on disk. If we only filter once per (page, destpage) pair, and a page is inlined into the same destpage more than once, then the second occurrence will render as the result of htmlizing .po source as if it was Markdown (or whatever the type of the corresponding master page is), which is never going to end well. The alreadyfiltered mechanism was added in commit 1e874b3f to avoid preprocessing loops, but I'm not sure where it could lead to a loop: filter hooks are only called from IkiWiki::filter, which is only called on page content from disk or on proposed content being previewed. According to , deleting the alreadyfiltered mechanism resolves the problem, as well as simplifying the code. Closes: #911356 Tested-by: intrigeri --- IkiWiki/Plugin/po.pm | 50 +------------------------------------------------- 1 file changed, 1 insertion(+), 49 deletions(-) (limited to 'IkiWiki') diff --git a/IkiWiki/Plugin/po.pm b/IkiWiki/Plugin/po.pm index 418e8e58a..13b98b739 100644 --- a/IkiWiki/Plugin/po.pm +++ b/IkiWiki/Plugin/po.pm @@ -51,7 +51,6 @@ sub import { hook(type => "checkcontent", id => "po", call => \&checkcontent); hook(type => "canremove", id => "po", call => \&canremove); hook(type => "canrename", id => "po", call => \&canrename); - hook(type => "editcontent", id => "po", call => \&editcontent); hook(type => "formbuilder_setup", id => "po", call => \&formbuilder_setup, last => 1); hook(type => "formbuilder", id => "po", call => \&formbuilder); @@ -303,9 +302,8 @@ sub filter (@) { my $page = $params{page}; my $destpage = $params{destpage}; my $content = $params{content}; - if (istranslation($page) && ! alreadyfiltered($page, $destpage)) { + if (istranslation($page)) { $content = po_to_markup($page, $content); - setalreadyfiltered($page, $destpage); } return $content; } @@ -520,15 +518,6 @@ sub canrename (@) { return undef; } -# As we're previewing or saving a page, the content may have -# changed, so tell the next filter() invocation it must not be lazy. -sub editcontent () { - my %params=@_; - - unsetalreadyfiltered($params{page}, $params{page}); - return $params{content}; -} - sub formbuilder_setup (@) { my %params=@_; my $form=$params{form}; @@ -736,42 +725,6 @@ sub myisselflink ($$) { return; } -# ,---- -# | Blackboxes for private data -# `---- - -{ - my %filtered; - - sub alreadyfiltered($$) { - my $page=shift; - my $destpage=shift; - - return exists $filtered{$page}{$destpage} - && $filtered{$page}{$destpage} eq 1; - } - - sub setalreadyfiltered($$) { - my $page=shift; - my $destpage=shift; - - $filtered{$page}{$destpage}=1; - } - - sub unsetalreadyfiltered($$) { - my $page=shift; - my $destpage=shift; - - if (exists $filtered{$page}{$destpage}) { - delete $filtered{$page}{$destpage}; - } - } - - sub resetalreadyfiltered() { - undef %filtered; - } -} - # ,---- # | Helper functions # `---- @@ -1146,7 +1099,6 @@ sub commit_and_refresh ($) { IkiWiki::rcs_update(); } # Reinitialize module's private variables. - resetalreadyfiltered(); resettranslationscache(); flushmemoizecache(); # Trigger a wiki refresh. -- cgit v1.2.3