You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@spamassassin.apache.org by jm...@apache.org on 2006/08/17 14:27:27 UTC

svn commit: r432216 - /spamassassin/branches/jm_re2c_hacks/lib/Mail/SpamAssassin/Plugin/Rule2XSBody.pm

Author: jm
Date: Thu Aug 17 05:27:26 2006
New Revision: 432216

URL: http://svn.apache.org/viewvc?rev=432216&view=rev
Log:
now back using just static text strings for re2xs -- no regexp metachars allowed at all.  results are 100% compatible with basic SA, although faster

Modified:
    spamassassin/branches/jm_re2c_hacks/lib/Mail/SpamAssassin/Plugin/Rule2XSBody.pm

Modified: spamassassin/branches/jm_re2c_hacks/lib/Mail/SpamAssassin/Plugin/Rule2XSBody.pm
URL: http://svn.apache.org/viewvc/spamassassin/branches/jm_re2c_hacks/lib/Mail/SpamAssassin/Plugin/Rule2XSBody.pm?rev=432216&r1=432215&r2=432216&view=diff
==============================================================================
--- spamassassin/branches/jm_re2c_hacks/lib/Mail/SpamAssassin/Plugin/Rule2XSBody.pm (original)
+++ spamassassin/branches/jm_re2c_hacks/lib/Mail/SpamAssassin/Plugin/Rule2XSBody.pm Thu Aug 17 05:27:26 2006
@@ -98,7 +98,7 @@
     # ignore rules marked for ReplaceTags work!
     # TODO: we should be able to order the 'finish_parsing_end'
     # plugin calls to do this.
-    next if ($conf->{rules_to_replace}{$rule});
+    next if ($conf->{rules_to_replace}->{$name});
 
     # we have the rule, and its regexp matches.  zero out the body
     # rule, so that the module can do the work instead
@@ -143,6 +143,8 @@
 
   dbg("zoom: run_body_hack for $ruletype start");
 
+  my $do_dbg = (would_log('dbg', 'zoom') > 1);
+
   my $scoresptr = $conf->{scores};
   my $modname = "Mail::SpamAssassin::CompiledRegexps::".$ruletype;
 
@@ -164,7 +166,9 @@
         # ignore 0-scored rules, of course
         next unless $scoresptr->{$rulename};
 
-        dbg("zoom: base found for $rulename: $line");
+        if ($do_dbg) {
+	  dbg("zoom: base found for $rulename: $line");
+        }
 
         # run the real regexp -- on this line alone
         &{'Mail::SpamAssassin::PerMsgStatus::'.$rulename.'_one_line_body_test'}
@@ -201,6 +205,9 @@
   foreach my $name (keys %{$rules}) {
     my $rule = $rules->{$name};
 
+    # ignore ReplaceTags rules
+    next if ($conf->{rules_to_replace}->{$name});
+
     my $base  = $self->extract_base($rule, 0);
     my $base2 = $self->extract_base($rule, 1);
 
@@ -410,10 +417,10 @@
             ).*$//gsx;
 
   $keep_quantifiers or $rule =~ s/(?<!\\)(?:
-              \*|
-              \+|
-              \?|
-              \{
+              .\*|	# remove the quantified char, too
+              .\+|
+              .\?|
+              .\{
             ).*$//gsx;
 
   $keep_alternations or $rule =~ s/(?<!\\)(?:
@@ -429,12 +436,17 @@
   # drop this one, after the reversing
   $rule =~ s/\(\?\!.*$//gsx;
 
+  # still problematic; kill all "x?" statements
+  $rule =~ s/.\?.*$//gsx;
+
   # simplify (..)? and (..|) to (..|z{0})
   # this wierd construct is to work around an re2c bug; (..|) doesn't
   # do what it should
-  $rule =~ s/\((.*?)\)\?/\($1\|z{0}\)/gs;
-  $rule =~ s/\((.*?)\|\)/\($1\|z{0}\)/gs;
-  $rule =~ s/\(\|(.*?)\)/\($1\|z{0}\)/gs;
+  if ($keep_alternations) {
+    $rule =~ s/\((.*?)\)\?/\($1\|z{0}\)/gs;
+    $rule =~ s/\((.*?)\|\)/\($1\|z{0}\)/gs;
+    $rule =~ s/\(\|(.*?)\)/\($1\|z{0}\)/gs;
+  }
 
   # re2xs doesn't like escaped brackets;
   # brackets in general, in fact
@@ -593,7 +605,7 @@
           \+ |
           \? |
         )
-        (.)\\/\\$3$2$1/gsx;
+        (.)(\\?)/$4$3$2$1/gsx;
 
   return $rule;
 }