X-Git-Url: http://git.vanrenterghem.biz/git.ikiwiki.info.git/blobdiff_plain/279db7860dc98bedbd8333bb7de57251dcfb223d..b90f8397f6f0c9c9e9de85ef04c32dba998c31a6:/IkiWiki/Plugin/htmlscrubber.pm?ds=inline diff --git a/IkiWiki/Plugin/htmlscrubber.pm b/IkiWiki/Plugin/htmlscrubber.pm index 3bdaccea1..7398c8478 100644 --- a/IkiWiki/Plugin/htmlscrubber.pm +++ b/IkiWiki/Plugin/htmlscrubber.pm @@ -10,6 +10,7 @@ use IkiWiki 2.00; our $safe_url_regexp; sub import { #{{{ + hook(type => "getsetup", id => "htmlscrubber", call => \&getsetup); hook(type => "sanitize", id => "htmlscrubber", call => \&sanitize); # Only known uri schemes are allowed to avoid all the ways of @@ -34,8 +35,32 @@ sub import { #{{{ $safe_url_regexp=qr/^(?:(?:$uri_schemes):|data:image\/|[^:]+(?:$|\/))/i; } # }}} +sub getsetup () { #{{{ + return + plugin => { + safe => 1, + rebuild => undef, + }, + htmlscrubber_skip => { + type => "pagespec", + example => "!*/Discussion", + description => "PageSpec specifying pages not to scrub", + link => "ikiwiki/PageSpec", + safe => 1, + rebuild => undef, + }, +} #}}} + sub sanitize (@) { #{{{ my %params=@_; + + if (exists $config{htmlscrubber_skip} && + length $config{htmlscrubber_skip} && + exists $params{destpage} && + pagespec_match($params{destpage}, $config{htmlscrubber_skip})) { + return $params{content}; + } + return scrubber()->scrub($params{content}); } # }}}