X-Git-Url: http://git.vanrenterghem.biz/git.ikiwiki.info.git/blobdiff_plain/f398ad035b973608d380c9939ea845d8e2a0cdc2..cd5a24d8b405902801ca710cb77d6cc3f802f90f:/IkiWiki/Plugin/blogspam.pm?ds=sidebyside diff --git a/IkiWiki/Plugin/blogspam.pm b/IkiWiki/Plugin/blogspam.pm index 8db3780e8..e48ed729f 100644 --- a/IkiWiki/Plugin/blogspam.pm +++ b/IkiWiki/Plugin/blogspam.pm @@ -4,6 +4,7 @@ package IkiWiki::Plugin::blogspam; use warnings; use strict; use IkiWiki 3.00; +use Encode; my $defaulturl='http://test.blogspam.net:8888/'; @@ -52,6 +53,7 @@ sub checkconfig () { eval q{ use RPC::XML; use RPC::XML::Client; + $RPC::XML::ENCODING = 'utf-8'; }; error $@ if $@; } @@ -60,14 +62,21 @@ sub checkcontent (@) { my %params=@_; my $session=$params{session}; - if (exists $config{blogspam_pagespec}) { - return undef - if ! pagespec_match($params{page}, $config{blogspam_pagespec}, - location => $params{page}); + my $spec='!admin()'; + if (exists $config{blogspam_pagespec} && + length $config{blogspam_pagespec}) { + $spec.=" and (".$config{blogspam_pagespec}.")"; } + my $user=$session->param("name"); + return undef unless pagespec_match($params{page}, $spec, + (defined $user ? (user => $user) : ()), + (defined $session->remote_addr() ? (ip => $session->remote_addr()) : ()), + location => $params{page}); + my $url=$defaulturl; $url = $config{blogspam_server} if exists $config{blogspam_server}; + my $client = RPC::XML::Client->new($url); my @options = split(",", $config{blogspam_options}) @@ -90,12 +99,12 @@ sub checkcontent (@) { my %req=( ip => $session->remote_addr(), - comment => defined $params{diff} ? $params{diff} : $params{content}, - subject => defined $params{subject} ? $params{subject} : "", - name => defined $params{author} ? $params{author} : "", - link => exists $params{url} ? $params{url} : "", + comment => encode_utf8(defined $params{diff} ? $params{diff} : $params{content}), + subject => encode_utf8(defined $params{subject} ? $params{subject} : ""), + name => encode_utf8(defined $params{author} ? $params{author} : ""), + link => encode_utf8(exists $params{url} ? $params{url} : ""), options => join(",", @options), - site => $config{url}, + site => encode_utf8($config{url}), version => "ikiwiki ".$IkiWiki::version, ); my $res = $client->send_request('testComment', \%req);