You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@spamassassin.apache.org by fe...@apache.org on 2006/07/31 18:46:50 UTC

svn commit: r427166 - in /spamassassin/rules/trunk/sandbox/felicity: 70_other.cf sandbox-felicity.pm

Author: felicity
Date: Mon Jul 31 09:46:49 2006
New Revision: 427166

URL: http://svn.apache.org/viewvc?rev=427166&view=rev
Log:
bug 5017: new test rule idea (base64 encoded line length)

Modified:
    spamassassin/rules/trunk/sandbox/felicity/70_other.cf
    spamassassin/rules/trunk/sandbox/felicity/sandbox-felicity.pm

Modified: spamassassin/rules/trunk/sandbox/felicity/70_other.cf
URL: http://svn.apache.org/viewvc/spamassassin/rules/trunk/sandbox/felicity/70_other.cf?rev=427166&r1=427165&r2=427166&view=diff
==============================================================================
--- spamassassin/rules/trunk/sandbox/felicity/70_other.cf (original)
+++ spamassassin/rules/trunk/sandbox/felicity/70_other.cf Mon Jul 31 09:46:49 2006
@@ -236,11 +236,14 @@
 header TVD_RATWARE_MSGID_02	Message-ID =~ /^[^<]*<[a-z]+\@/
 
 ########################################################################
-#loadplugin Mail::SpamAssassin::Plugin::Sandbox::felicity sandbox-felicity.pm
-#
-#ifplugin Mail::SpamAssassin::Plugin::Sandbox::felicity
-#body RENDERED_DIFFERENTLY	eval:check_rendered_different()
-#endif
+loadplugin Mail::SpamAssassin::Plugin::Sandbox::felicity sandbox-felicity.pm
+
+ifplugin Mail::SpamAssassin::Plugin::Sandbox::felicity
+body BASE64_LENGTH_78	eval:check_base64_length('78')
+body BASE64_LENGTH_79	eval:check_base64_length('79')
+body BASE64_LENGTH_80	eval:check_base64_length('80')
+body BASE64_LENGTH_90	eval:check_base64_length('90')
+endif
 ########################################################################
 
 uri T_TVD_IP_SING_HEX	m@^https?://0x[0-9a-f]+(?:[:/]|$)@i

Modified: spamassassin/rules/trunk/sandbox/felicity/sandbox-felicity.pm
URL: http://svn.apache.org/viewvc/spamassassin/rules/trunk/sandbox/felicity/sandbox-felicity.pm?rev=427166&r1=427165&r2=427166&view=diff
==============================================================================
--- spamassassin/rules/trunk/sandbox/felicity/sandbox-felicity.pm (original)
+++ spamassassin/rules/trunk/sandbox/felicity/sandbox-felicity.pm Mon Jul 31 09:46:49 2006
@@ -36,19 +36,40 @@
   bless ($self, $class);
 
   # the important bit!
-#  $self->register_eval_rule ("check_rendered_different");
+  $self->register_eval_rule ("check_base64_length");
 
   return $self;
 }
 
-#sub check_rendered_different {
-#  my $plugin = shift;	# remove for EvalTests
-#  my $self = shift;	# PMS
-#
-#  foreach my $p ($self->{msg}->find_parts(qr@^text/plain$@i)) {
-#  }
-#  
-#  return 0;
-#}
+sub check_base64_length {
+  my $self = shift;
+  my $pms = shift;
+  shift; # body array, unnecessary
+  my $len = shift;
+
+  if (!defined $pms->{base64_length}) {
+    $pms->{base64_length} = $self->_check_base64_length($pms->{msg});
+  }
+
+  return $pms->{base64_length} >= $len;
+}
+
+sub _check_base64_length {
+  my $self = shift;
+  my $msg = shift;
+
+  my $result = 0;
+
+  foreach my $p ($msg->find_parts(qr@.@, 1)) {
+    my $cte = lc $p->get_header('content-transfer-encoding') || '';
+    next if ($cte !~ /^base64$/);
+    foreach my $l ( @{$p->raw()} ) {
+      my $len = length $l;
+      $result = $len if ($len > $result);
+    }
+  }
+  
+  return $result;
+}
 
 1;