From e0898ae1a8e64a12c4e47b3f922d6cf1fad4f31c Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Tue, 14 Sep 2010 15:23:16 -0400 Subject: blogspam: Fix crash when content contained utf-8. I also tried setting RPC::XML::ENCODING but that did not prevent the crash, and it seems that blogspam.net doesn't like getting xml encoded in unicode, since it mis-flagged comments as spammy that way that are normally allowed through. --- IkiWiki/Plugin/blogspam.pm | 12 +++++++----- debian/changelog | 1 + .../blog_spam_plugin_not_allowing_non-ASCII_chars__63__.mdwn | 5 +++++ 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/IkiWiki/Plugin/blogspam.pm b/IkiWiki/Plugin/blogspam.pm index 8db3780e8..f0b6cb2a2 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/'; @@ -68,6 +69,7 @@ sub checkcontent (@) { 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 +92,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); diff --git a/debian/changelog b/debian/changelog index 8b127b574..0eb5810d0 100644 --- a/debian/changelog +++ b/debian/changelog @@ -18,6 +18,7 @@ ikiwiki (3.20100832) UNRELEASED; urgency=low * actiontabs: Improve tab padding. * blueview: Fix display of links to translated pages in the page header. * Set isPermaLink="no" for guids in rss feeds. + * blogspam: Fix crash when content contained utf-8. -- Joey Hess Tue, 07 Sep 2010 12:08:05 -0400 diff --git a/doc/bugs/blog_spam_plugin_not_allowing_non-ASCII_chars__63__.mdwn b/doc/bugs/blog_spam_plugin_not_allowing_non-ASCII_chars__63__.mdwn index 22242a97f..265040d67 100644 --- a/doc/bugs/blog_spam_plugin_not_allowing_non-ASCII_chars__63__.mdwn +++ b/doc/bugs/blog_spam_plugin_not_allowing_non-ASCII_chars__63__.mdwn @@ -8,3 +8,8 @@ This seems to happen because I had a non-ASCII character in the comment (an elli The interesting part is that the comment preview works fine, just the save fails. Probably this means that the blogspam plugin is the culprit (hence the error in RPC::XML::Client library). I'm using version 3.20100815~bpo50+. Thanks! + +> I've filed an upstream bug about this on RPC::XML: +> +> +> Worked around it in blogspam by decoding. --[[Joey]] -- cgit v1.2.3