https://issues.apache.org/SpamAssassin/show_bug.cgi?id=6573

Kevin A. McGrail <[email protected]> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |[email protected]

--- Comment #2 from Kevin A. McGrail <[email protected]> 2011-05-05 11:56:02 
UTC ---
(In reply to comment #1)
> Thanks! Now fixed I suppose:
> 
> trunk:
>   $ svn ci -m 'Bug 6573: Report for IPv6 IP hitting DNS BL/WL is broken'
>   Sending lib/Mail/SpamAssassin/Dns.pm
> Committed revision 1099506.

We are talking about this patch, yes?  If so, I don't use IPv6 but I really
liked the empty if comment change.

I don't use IPv6 but I was looking for a type eq 'AA' so if this works, I see
the logic as good but it confuses me a bit.

Index: Dns.pm
===================================================================
--- Dns.pm      (revision 1040623)
+++ Dns.pm      (working copy)
@@ -182,15 +182,26 @@
   my ($self, $rule, $question, $answer) = @_;

   my $log = "";
-  if (substr($rule, 0, 2) ne "__") {
-    if ($answer->type eq 'TXT') {
-      $log = $answer->rdatastr;
-      $log =~ s/^"(.*)"$/$1/;
-      $log =~ s/(?<![<([])(https?:\/\/\S+)/<$1>/gi;
+  if (substr($rule, 0, 2) eq "__") {
+    # don't bother with meta rules
+  } elsif ($answer->type eq 'TXT') {
+    local $1;
+    $log = $answer->rdatastr;
+    $log =~ s/^"(.*)"$/$1/;
+    $log =~ s/(?<![<([])(https?:\/\/\S+)/<$1>/gi;
+  } else {  # assuming $answer->type eq 'A'
+    local($1,$2,$3,$4,$5);
+    if ($question->string =~ m/^((?:[0-9a-fA-F]\.){32})(\S+\w)/) {
+      $log = ' listed in ' . lc($2);
+      my $ipv6addr = join('', reverse split(/\./, lc $1));
+      $ipv6addr =~ s/\G(....)/$1:/g;  chop $ipv6addr;
+      $ipv6addr =~ s/:0{1,3}/:/g;
+      $log = $ipv6addr . $log;
+    } elsif ($question->string =~ m/^(\d+)\.(\d+)\.(\d+)\.(\d+)\.(\S+\w)/) {
+      $log = "$4.$3.$2.$1 listed in " . lc($5);
+    } else {
+      $log = 'listed in ' . $question->string;
     }
-    elsif ($question->string =~ m/^(\d+)\.(\d+)\.(\d+)\.(\d+)\.(\S+\w)/) {
-      $log = "$4.$3.$2.$1 listed in ".lc($5);
-    }
   }

   # TODO: this may result in some log messages appearing under the
@@ -281,9 +292,9 @@
   while (my ($subtest, $rule) = each %{ $self->{dnspost}->{$set} }) {
     next if $self->{tests_already_hit}->{$rule};

-    # exact substr (usually IP address)
-    if ($subtest eq $rdatastr) {
-      $self->dnsbl_hit($rule, $question, $answer);
+    if ($subtest =~ /^\d+\.\d+\.\d+\.\d+$/) {
+      # test for exact equality, not a regexp (usually IP address)
+      $self->dnsbl_hit($rule, $question, $answer)  if $subtest eq $rdatastr;
     }
     # senderbase
     elsif ($subtest =~ s/^sb://) {

-- 
Configure bugmail: 
https://issues.apache.org/SpamAssassin/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

Reply via email to