You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@spamassassin.apache.org by mm...@apache.org on 2010/10/25 17:15:44 UTC

svn commit: r1027163 - /spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/BodyRuleBaseExtractor.pm

Author: mmartinec
Date: Mon Oct 25 15:15:42 2010
New Revision: 1027163

URL: http://svn.apache.org/viewvc?rev=1027163&view=rev
Log:
Bug 6392: fix one more case of a 'goto into a construct', this one occured with sa-compile

Modified:
    spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/BodyRuleBaseExtractor.pm

Modified: spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/BodyRuleBaseExtractor.pm
URL: http://svn.apache.org/viewvc/spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/BodyRuleBaseExtractor.pm?rev=1027163&r1=1027162&r2=1027163&view=diff
==============================================================================
--- spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/BodyRuleBaseExtractor.pm (original)
+++ spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/BodyRuleBaseExtractor.pm Mon Oct 25 15:15:42 2010
@@ -176,31 +176,37 @@ NEXT_RULE:
     }
 
     # ignore ReplaceTags rules
-    # TODO: need cleaner way to do this
-    goto NO if ($conf->{rules_to_replace}->{$name});
+    my $is_a_replacetags_rule = $conf->{rules_to_replace}->{$name};
+    my ($minlen, $lossy, @bases);
 
-    my ($lossy, @bases);
-
-    eval {  # catch die()s
-      my ($qr, $mods) = $self->simplify_and_qr_regexp($rule);
-      ($lossy, @bases) = $self->extract_hints($rule, $qr, $mods);
-      1;
-    } or do {
-      my $eval_stat = $@ ne '' ? $@ : "errno=$!";  chomp $eval_stat;
-      dbg("zoom: giving up on regexp: $eval_stat");
-    };
-
-    # if any of the extracted hints in a set are too short, the entire
-    # set is invalid; this is because each set of N hints represents just
-    # 1 regexp.
-    my $minlen;
-    foreach my $str (@bases) {
-      my $len = length fixup_re($str); # bug 6143: count decoded characters
-      if ($len < $min_chars) { $minlen = undef; @bases = (); last; }
-      elsif (!defined($minlen) || $len < $minlen) { $minlen = $len; }
+    if (!$is_a_replacetags_rule) {
+      eval {  # catch die()s
+        my ($qr, $mods) = $self->simplify_and_qr_regexp($rule);
+        ($lossy, @bases) = $self->extract_hints($rule, $qr, $mods);
+        1;
+      } or do {
+        my $eval_stat = $@ ne '' ? $@ : "errno=$!";  chomp $eval_stat;
+        dbg("zoom: giving up on regexp: $eval_stat");
+      };
+
+      # if any of the extracted hints in a set are too short, the entire
+      # set is invalid; this is because each set of N hints represents just
+      # 1 regexp.
+      foreach my $str (@bases) {
+        my $len = length fixup_re($str); # bug 6143: count decoded characters
+        if ($len < $min_chars) { $minlen = undef; @bases = (); last; }
+        elsif (!defined($minlen) || $len < $minlen) { $minlen = $len; }
+      }
     }
 
-    if ($minlen && @bases) {
+    if ($is_a_replacetags_rule || !$minlen || !@bases) {
+      dbg("zoom: ignoring %s %s",
+          $is_a_replacetags_rule ? 'replace rule' : 'NO',  $rule);
+      push @failed, { orig => $rule };
+      $cached->{rule_bases}->{$cachekey} = { };
+      $no++;
+    }
+    else {
       # dbg("zoom: YES <base>$base</base> <origrule>$rule</origrule>");
 
       # figure out if we have e.g. ["foo", "foob", "foobar"]; in this
@@ -229,13 +235,6 @@ NEXT_RULE:
       $cached->{rule_bases}->{$cachekey} = { g => \@forcache };
       $yes++;
     }
-    else {
-NO:
-      dbg("zoom: NO $rule");
-      push @failed, { orig => $rule };
-      $cached->{rule_bases}->{$cachekey} = { };
-      $no++;
-    }
   }
 
   $self->{show_progress} and $progress and $progress->final();