[Mimedefang] Rejecting Cyrillic
Kevin A. McGrail
kmcgrail at pccc.com
Thu Apr 16 22:37:33 EDT 2009
Richard,
I've been looking at this and the code seems to work but I wonder if you
can't achieve the same result with just a regexp:
if ($Subject =~ /=\?(koi8-r|Windows-1251)\?/i) {
}
I've included a test stub below to show this information based on these code
pages:
http://en.wikipedia.org/wiki/CP1251
http://en.wikipedia.org/wiki/KOI8-R
Additionally, I'm wondering if you have looked at the SpamAssassin Plug
TextCat and enabled it in v310.pre.
# TextCat - language guesser
#
loadplugin Mail::SpamAssassin::Plugin::TextCat
Then add something like this to your local config
ok_locales en
ok_languages en
man Mail::SpamAssassin::Plugin::TextCat for more information.
Anyway, here's the quick modifications I ran to look at this with two test
subjects I found. NOTE: If you understand these languages, please don't
blame me for the content. I have no idea what they say.
use Encode;
use MIME::Words;
$Subject[0] = "Subject:
=?gb2312?B?v+y93dans9ajrM341b7T0LXAIKGqIM73w8XX07y8yvXWp7PW0+u3/g==?=
=?gb2312?B?zvHN+NW+zqrE+szhuam0tNDCt/7O8Q==?=";
$Subject[1] = "Subject:
=?koi8-r?B?8sHT0NLPxMHWwSDP0snHyc7BzNjO2cgg0sXQzMnLIN7B08/XLiDw0g==?=
=?koi8-r?B?ySDL1dLTxSAxIMTPzMzB0iA9IDI1INLVwszFyiwg3sHT2SDT1M/R1A==?=
=?koi8-r?B?IM3FztjbxSAxMCDU2dPR3i4g88HK1CDLz9DJyjo=?=";
$Subject[2] = "Subject:
=?Windows-1251?B?IP3r5ezl7fL7IPPx7+X47e7pIO/w5efl7fLg9ujo?=";
foreach $Subject (@Subject) {
if ($Subject =~ /=\?(koi8-r|Windows-1251)\?/i) {
print "DEBUG: Cyrillic Test 1\n";
}
if ($Subject =~ m/=\?.+\?.+\?.+\?=/) {
my $decoded_subject = "";
foreach my $pair (MIME::Words::decode_mimewords($Subject))
{
if (defined($pair->[1]) && $pair->[1] ne "")
{
$decoded_subject .= decode($pair->[1], $pair->[0]);
}
else
{
$decoded_subject .= decode("us-ascii", $pair->[0]);
}
}
if ($decoded_subject =~ m/\p{Cyrillic}/)
{
# DO SOMETHING HERE: REJECT, ETC.
print "DEBUG: Cyrillic Test 2\n";
}
}
}
More information about the MIMEDefang
mailing list