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 2015/03/02 20:34:12 UTC

svn commit: r1663406 - /spamassassin/trunk/lib/Mail/SpamAssassin/Conf.pm

Author: mmartinec
Date: Mon Mar  2 19:34:11 2015
New Revision: 1663406

URL: http://svn.apache.org/r1663406
Log:
Bug 7150: Allow scoped IP address in the dns_server config option

Modified:
    spamassassin/trunk/lib/Mail/SpamAssassin/Conf.pm

Modified: spamassassin/trunk/lib/Mail/SpamAssassin/Conf.pm
URL: http://svn.apache.org/viewvc/spamassassin/trunk/lib/Mail/SpamAssassin/Conf.pm?rev=1663406&r1=1663405&r2=1663406&view=diff
==============================================================================
--- spamassassin/trunk/lib/Mail/SpamAssassin/Conf.pm (original)
+++ spamassassin/trunk/lib/Mail/SpamAssassin/Conf.pm Mon Mar  2 19:34:11 2015
@@ -1528,13 +1528,16 @@ argument can either be an IPv4 or IPv6 a
 brackets, and optionally followed by a colon and a port number. In absence
 of a port number a standard port number 53 is assumed. When an IPv6 address
 is specified along with a port number, the address B<must> be enclosed in
-brackets to avoid parsing ambiguity regarding a colon separator,
+brackets to avoid parsing ambiguity regarding a colon separator. A scoped
+link-local IP address is allowed (assuming underlying modules allow it).
 
 Examples :
  dns_server 127.0.0.1
  dns_server 127.0.0.1:53
  dns_server [127.0.0.1]:53
  dns_server [::1]:53
+ dns_server fe80::1%lo0
+ dns_server [fe80::1%lo0]:53
 
 In absence of I<dns_server> directives, the list of name servers is provided
 by Net::DNS module, which typically obtains the list from /etc/resolv.conf,
@@ -1551,16 +1554,19 @@ documentation for details.
       my($address,$port); local($1,$2,$3);
       if ($value =~ /^(?: \[ ([^\]]*) \] | ([^:]*) ) : (\d+) \z/sx) {
         $address = defined $1 ? $1 : $2;  $port = $3;
-      } elsif ($value =~ /^(?: \[ ([^\]]*) \] | ([0-9a-fA-F.:]+) ) \z/sx) {
+      } elsif ($value =~ /^(?: \[ ([^\]]*) \] |
+                               ([0-9A-F.:]+ (?: %[A-Z0-9._~-]* )? ) ) \z/six) {
         $address = defined $1 ? $1 : $2;  $port = '53';
       } else {
         return $INVALID_VALUE;
       }
-      my $IP_ADDRESS = IP_ADDRESS;
+      my $scope = '';  # scoped IP address?
+      $scope = $1  if $address =~ s/ ( % [A-Z0-9._~-]* ) \z//xsi;
+      my $IP_ADDRESS = IP_ADDRESS;  # IP_ADDRESS regexp does not handle scope
       if ($address =~ /$IP_ADDRESS/ && $port >= 1 && $port <= 65535) {
         $self->{dns_servers} = []  if !$self->{dns_servers};
         # checked, untainted, stored in a normalized form
-        push(@{$self->{dns_servers}}, untaint_var("[$address]:$port"));
+        push(@{$self->{dns_servers}}, untaint_var("[$address$scope]:$port"));
       } else {
         return $INVALID_VALUE;
       }