You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@spamassassin.apache.org by he...@apache.org on 2019/08/05 00:25:09 UTC

svn commit: r1864400 - in /spamassassin/trunk: lib/Mail/ lib/Mail/SpamAssassin/ lib/Mail/SpamAssassin/BayesStore/ lib/Mail/SpamAssassin/Message/ lib/Mail/SpamAssassin/Message/Metadata/ lib/Mail/SpamAssassin/Plugin/ t/

Author: hege
Date: Mon Aug  5 00:25:08 2019
New Revision: 1864400

URL: http://svn.apache.org/viewvc?rev=1864400&view=rev
Log:
- new qr// constants IS_IP_ADDRESS, IS_IPV4_ADDRESS, IS_IP_PRIVATE, IS_LOCALHOST for exact matching
- other small re optimizations and cleanups

Modified:
    spamassassin/trunk/lib/Mail/SpamAssassin.pm
    spamassassin/trunk/lib/Mail/SpamAssassin/ArchiveIterator.pm
    spamassassin/trunk/lib/Mail/SpamAssassin/BayesStore/BDB.pm
    spamassassin/trunk/lib/Mail/SpamAssassin/BayesStore/DBM.pm
    spamassassin/trunk/lib/Mail/SpamAssassin/Conf.pm
    spamassassin/trunk/lib/Mail/SpamAssassin/Constants.pm
    spamassassin/trunk/lib/Mail/SpamAssassin/DnsResolver.pm
    spamassassin/trunk/lib/Mail/SpamAssassin/GeoDB.pm
    spamassassin/trunk/lib/Mail/SpamAssassin/Message.pm
    spamassassin/trunk/lib/Mail/SpamAssassin/Message/Metadata/Received.pm
    spamassassin/trunk/lib/Mail/SpamAssassin/Message/Node.pm
    spamassassin/trunk/lib/Mail/SpamAssassin/PerMsgStatus.pm
    spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/ASN.pm
    spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/AskDNS.pm
    spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/Bayes.pm
    spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/BodyEval.pm
    spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/DNSEval.pm
    spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/FreeMail.pm
    spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/HTTPSMismatch.pm
    spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/HeaderEval.pm
    spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/MIMEEval.pm
    spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/RelayEval.pm
    spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/URIDNSBL.pm
    spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/URIDetail.pm
    spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/URILocalBL.pm
    spamassassin/trunk/lib/Mail/SpamAssassin/RegistryBoundaries.pm
    spamassassin/trunk/lib/Mail/SpamAssassin/Util.pm
    spamassassin/trunk/t/all_modules.t

Modified: spamassassin/trunk/lib/Mail/SpamAssassin.pm
URL: http://svn.apache.org/viewvc/spamassassin/trunk/lib/Mail/SpamAssassin.pm?rev=1864400&r1=1864399&r2=1864400&view=diff
==============================================================================
--- spamassassin/trunk/lib/Mail/SpamAssassin.pm (original)
+++ spamassassin/trunk/lib/Mail/SpamAssassin.pm Mon Aug  5 00:25:08 2019
@@ -2069,15 +2069,15 @@ sub expand_name {
   if (am_running_on_windows()) {
     my $userprofile = $ENV{USERPROFILE} || '';
 
-    return $userprofile if ($userprofile && $userprofile =~ m/^[a-z]\:[\/\\]/oi);
-    return $userprofile if ($userprofile =~ m/^\\\\/o);
+    return $userprofile if ($userprofile && $userprofile =~ m/^[a-z]\:[\/\\]/i);
+    return $userprofile if ($userprofile =~ m/^\\\\/);
 
-    return $home if ($home && $home =~ m/^[a-z]\:[\/\\]/oi);
-    return $home if ($home =~ m/^\\\\/o);
+    return $home if ($home && $home =~ m/^[a-z]\:[\/\\]/i);
+    return $home if ($home =~ m/^\\\\/);
 
     return '';
   } else {
-    return $home if ($home && $home =~ /\//o);
+    return $home if ($home && index($home, '/') != -1);
     return (getpwnam($name))[7] if ($name ne '');
     return (getpwuid($>))[7];
   }
@@ -2244,8 +2244,8 @@ sub find_all_addrs_in_line {
   my ($self, $line) = @_;
 
   # a more permissive pattern based on "dot-atom" as per RFC2822
-  my $ID_PATTERN   = '[-a-z0-9_\+\:\=\!\#\$\%\&\*\^\?\{\}\|\~\/\.]+';
-  my $HOST_PATTERN = '[-a-z0-9_\+\:\/]+';
+  my $ID_PATTERN   = qr/[-a-zA-Z0-9_\+\:\=\!\#\$\%\&\*\^\?\{\}\|\~\/\.]+/;
+  my $HOST_PATTERN = qr/[-a-zA-Z0-9_\+\:\/]+/;
 
   my @addrs;
   my %seen;

Modified: spamassassin/trunk/lib/Mail/SpamAssassin/ArchiveIterator.pm
URL: http://svn.apache.org/viewvc/spamassassin/trunk/lib/Mail/SpamAssassin/ArchiveIterator.pm?rev=1864400&r1=1864399&r2=1864400&view=diff
==============================================================================
--- spamassassin/trunk/lib/Mail/SpamAssassin/ArchiveIterator.pm (original)
+++ spamassassin/trunk/lib/Mail/SpamAssassin/ArchiveIterator.pm Mon Aug  5 00:25:08 2019
@@ -25,7 +25,7 @@ use warnings;
 use re 'taint';
 
 use Errno qw(ENOENT EACCES EBADF);
-use Mail::SpamAssassin::Util;
+use Mail::SpamAssassin::Util qw(compile_regexp);
 use Mail::SpamAssassin::Constants qw(:sa);
 use Mail::SpamAssassin::Logger;
 use Mail::SpamAssassin::AICache;
@@ -432,7 +432,7 @@ sub _run_mailbox {
   my $size = 0;
   for ($!=0; <INPUT>; $!=0) {
     #Changed Regex to use option Per bug 6703
-    last if (substr($_,0,5) eq "From " && @msg && /$self->{opt_from_regex}/o);
+    last if (/^From / && @msg && $_ =~ $self->{opt_from_regex});
     $size += length($_);
     push (@msg, $_);
 
@@ -663,11 +663,15 @@ sub _set_default_message_selection_opts
   $self->{opt_want_date} = 1 unless (defined $self->{opt_want_date});
   $self->{opt_cache} = 0 unless (defined $self->{opt_cache});
   #Changed Regex to include boundaries for Communigate Pro versions (5.2.x and later). per Bug 6413
-  $self->{opt_from_regex} = '^From \S+  ?(\S\S\S \S\S\S .?\d .?\d:\d\d:\d\d \d{4}|.?\d-\d\d-\d{4}_\d\d:\d\d:\d\d_)' unless (defined $self->{opt_from_regex});
-
-  #STRIP LEADING AND TRAILING / FROM REGEX FOR OPTION
-  $self->{opt_from_regex} =~ s/^\///;
-  $self->{opt_from_regex} =~ s/\/$//;
+  if (!defined $self->{opt_from_regex}) {
+    $self->{opt_from_regex} = qr/^From \S+  ?(\S\S\S \S\S\S .?\d .?\d:\d\d:\d\d \d{4}|.?\d-\d\d-\d{4}_\d\d:\d\d:\d\d_)/;
+  } elsif (ref($self->{opt_from_regex}) ne 'Regexp') {
+    my ($rec, $err) = compile_regexp($self->{opt_from_regex}, 1);
+    if (!$rec) {
+      die "fatal: invalid mbox_format_from_regex '$self->{opt_from_regex}': $err\n";
+    }
+    $self->{opt_from_regex} = $rec;
+  }
 
   dbg("archive-iterator: _set_default_message_selection_opts After: Scanprob[$self->{opt_scanprob}], want_date[$self->{opt_want_date}], cache[$self->{opt_cache}], from_regex[$self->{opt_from_regex}]");
 
@@ -966,7 +970,7 @@ sub _scan_mailbox {
 	    }
 	  }
           #Changed Regex to use option Per bug 6703
-	  if (substr($_,0,5) eq "From " && /$self->{opt_from_regex}/o) {
+	  if (/^From / && $_ =~ $self->{opt_from_regex}) {
 	    $in_header = 1;
 	    $first = $_;
 	    $start = $where;
@@ -1093,10 +1097,9 @@ sub _scan_mbx {
 
       # skip mbx headers to the first email...
       seek(INPUT,2048,0)  or die "cannot reposition file to 2048: $!";
-      my $sep = MBX_SEPARATOR;
 
       for ($!=0; <INPUT>; $!=0) {
-        if ($_ =~ /$sep/) {
+        if ($_ =~ MBX_SEPARATOR) {
 	  my $offset = tell INPUT;
           $offset >= 0  or die "cannot obtain file position: $!";
 	  my $size = $2;

Modified: spamassassin/trunk/lib/Mail/SpamAssassin/BayesStore/BDB.pm
URL: http://svn.apache.org/viewvc/spamassassin/trunk/lib/Mail/SpamAssassin/BayesStore/BDB.pm?rev=1864400&r1=1864399&r2=1864400&view=diff
==============================================================================
--- spamassassin/trunk/lib/Mail/SpamAssassin/BayesStore/BDB.pm (original)
+++ spamassassin/trunk/lib/Mail/SpamAssassin/BayesStore/BDB.pm Mon Aug  5 00:25:08 2019
@@ -39,6 +39,7 @@ use Digest::SHA qw(sha1);
 
 use Mail::SpamAssassin::BayesStore;
 use Mail::SpamAssassin::Logger;
+use Mail::SpamAssassin::Util qw(compile_regexp);
 
 our @ISA = qw( Mail::SpamAssassin::BayesStore );
 
@@ -647,6 +648,14 @@ sub dump_tokens {
   my($self, $template, $regex, @vars) = @_;
   dbg("bayes: dump_tokens starting");
 
+  if (defined $regex) {
+    my ($rec, $err) = compile_regexp($regex, 2);
+    if (!$rec) {
+      die "Invalid dump_tokens regex '$regex': $err\n";
+    }
+    $regex = $rec;
+  }
+
   my $cursor = $self->{handles}->{tokens}->db_cursor;
   $cursor or die "Couldn't get cursor: $BerkeleyDB::Error";
   my ($token, $value) = ("", "");

Modified: spamassassin/trunk/lib/Mail/SpamAssassin/BayesStore/DBM.pm
URL: http://svn.apache.org/viewvc/spamassassin/trunk/lib/Mail/SpamAssassin/BayesStore/DBM.pm?rev=1864400&r1=1864399&r2=1864400&view=diff
==============================================================================
--- spamassassin/trunk/lib/Mail/SpamAssassin/BayesStore/DBM.pm (original)
+++ spamassassin/trunk/lib/Mail/SpamAssassin/BayesStore/DBM.pm Mon Aug  5 00:25:08 2019
@@ -30,7 +30,7 @@ use File::Path;
 use Digest::SHA qw(sha1);
 
 use Mail::SpamAssassin;
-use Mail::SpamAssassin::Util qw(untaint_var am_running_on_windows);
+use Mail::SpamAssassin::Util qw(untaint_var am_running_on_windows compile_regexp);
 use Mail::SpamAssassin::BayesStore;
 use Mail::SpamAssassin::Logger;
 
@@ -988,9 +988,17 @@ sub get_storage_variables {
 sub dump_db_toks {
   my ($self, $template, $regex, @vars) = @_;
 
+  if (defined $regex) {
+    my ($rec, $err) = compile_regexp($regex, 2);
+    if (!$rec) {
+      die "Invalid dump_tokens regex '$regex': $err\n";
+    }
+    $regex = $rec;
+  }
+
   while (my ($tok, $tokvalue) = each %{$self->{db_toks}}) {
     next if ($tok =~ MAGIC_RE); # skip magic tokens
-    next if (defined $regex && ($tok !~ /$regex/o));
+    next if (defined $regex && $tok !~ /$regex/o);
 
     # We have the value already, so just unpack it.
     my ($ts, $th, $atime) = $self->tok_unpack ($tokvalue);

Modified: spamassassin/trunk/lib/Mail/SpamAssassin/Conf.pm
URL: http://svn.apache.org/viewvc/spamassassin/trunk/lib/Mail/SpamAssassin/Conf.pm?rev=1864400&r1=1864399&r2=1864400&view=diff
==============================================================================
--- spamassassin/trunk/lib/Mail/SpamAssassin/Conf.pm (original)
+++ spamassassin/trunk/lib/Mail/SpamAssassin/Conf.pm Mon Aug  5 00:25:08 2019
@@ -1642,8 +1642,7 @@ documentation for details.
       }
       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) {
+      if ($address =~ IS_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$scope]:$port"));
@@ -4143,13 +4142,14 @@ Plugins can override this internally if
     type => $Mail::SpamAssassin::Conf::CONF_TYPE_STRING,
     code => sub {
       my ($self, $key, $value, $line) = @_;
-      if ($value eq 'GeoIP2::Database::Reader' || $value eq 'GeoIP2') {
+      $value = lc $value;
+      if ($value eq 'geoip2::database::reader' || $value eq 'geoip2') {
         $self->{geodb}->{module} = 'geoip2';
-      } elsif ($value eq 'Geo::IP' || $value eq 'GeoIP') {
+      } elsif ($value eq 'geo::ip' || $value eq 'geoip') {
         $self->{geodb}->{module} = 'geoip';
-      } elsif ($value eq 'IP::Country::DB_File' || $value eq 'DB_File') {
+      } elsif ($value eq 'ip::country::db_file' || $value eq 'db_file') {
         $self->{geodb}->{module} = 'dbfile';
-      } elsif ($value eq 'IP::Country::Fast' || $value eq 'Fast') {
+      } elsif ($value eq 'ip::country::fast' || $value eq 'fast') {
         $self->{geodb}->{module} = 'fast';
       } else {
         return $Mail::SpamAssassin::Conf::INVALID_VALUE;
@@ -4857,13 +4857,13 @@ sub trim_rules {
     push(@all_rules, $self->get_rule_keys($rule_type));
   }
 
-  my @rules_to_keep = grep(/$rec/, @all_rules);
+  my @rules_to_keep = grep(/$rec/o, @all_rules);
 
   if (@rules_to_keep == 0) {
     die "config: trim_rules: all rules excluded, nothing to test\n";
   }
 
-  my @meta_tests    = grep(/$rec/, $self->get_rule_keys('meta_tests'));
+  my @meta_tests    = grep(/$rec/o, $self->get_rule_keys('meta_tests'));
   foreach my $meta (@meta_tests) {
     push(@rules_to_keep, $self->add_meta_depends($meta))
   }

Modified: spamassassin/trunk/lib/Mail/SpamAssassin/Constants.pm
URL: http://svn.apache.org/viewvc/spamassassin/trunk/lib/Mail/SpamAssassin/Constants.pm?rev=1864400&r1=1864399&r2=1864400&view=diff
==============================================================================
--- spamassassin/trunk/lib/Mail/SpamAssassin/Constants.pm (original)
+++ spamassassin/trunk/lib/Mail/SpamAssassin/Constants.pm Mon Aug  5 00:25:08 2019
@@ -34,6 +34,7 @@ our(@BAYES_VARS, @IP_VARS, @SA_VARS, %EX
 BEGIN { 
   @IP_VARS = qw(
 	IP_IN_RESERVED_RANGE IP_PRIVATE LOCALHOST IPV4_ADDRESS IP_ADDRESS
+	IS_IP_PRIVATE IS_LOCALHOST IS_IPV4_ADDRESS IS_IP_ADDRESS
   );
   @BAYES_VARS = qw(
 	DUMP_MAGIC DUMP_TOKEN DUMP_BACKUP 
@@ -168,7 +169,10 @@ use constant IP_PRIVATE => qr{^(?:
     )
     (?![a-f0-9:])
   )
-)}oxi;
+)}xi;
+
+# exact match
+use constant IS_IP_PRIVATE => qr/^${\(IP_PRIVATE)}$/;
 
 # backward compatibility
 use constant IP_IN_RESERVED_RANGE => IP_PRIVATE;
@@ -246,7 +250,10 @@ use constant LOCALHOST => qr/
 		      )
 		      (?![a-f0-9:])
 		    )
-		  /oxi;
+		  /xi;
+
+# exact match
+use constant IS_LOCALHOST => qr/^${\(LOCALHOST)}$/;
 
 # ---------------------------------------------------------------------------
 # an IP address, in IPv4 format only.
@@ -256,11 +263,13 @@ use constant IPV4_ADDRESS => qr/\b
                     (?:1\d\d|2[0-4]\d|25[0-5]|[1-9]\d|\d)\.
                     (?:1\d\d|2[0-4]\d|25[0-5]|[1-9]\d|\d)\.
                     (?:1\d\d|2[0-4]\d|25[0-5]|[1-9]\d|\d)
-                  \b/ox;
+                  \b/x;
+
+# exact match
+use constant IS_IPV4_ADDRESS => qr/^${\(IPV4_ADDRESS)}$/;
 
 # ---------------------------------------------------------------------------
-# an IP address, in IPv4, IPv4-mapped-in-IPv6, or IPv6 format.  NOTE: cannot
-# just refer to $IPV4_ADDRESS, due to perl bug reported in nesting qr//s. :(
+# an IP address, in IPv4, IPv4-mapped-in-IPv6, or IPv6 format.
 #
 use constant IP_ADDRESS => qr/
 		    (?:
@@ -344,7 +353,10 @@ use constant IP_ADDRESS => qr/
 		      )
 		      (?![a-f0-9:])
 		    )
-		  /oxi;
+		  /xi;
+
+# exact match
+use constant IS_IP_ADDRESS => qr/^${\(IP_ADDRESS)}$/;
 
 # ---------------------------------------------------------------------------
 
@@ -386,7 +398,7 @@ use constant ARITH_EXPRESSION_LEXER => q
         !=|                                     # NEQ
         [\+\-\*\/]|                             # Mathematical Operator
         [\?:]                                   # ? : Operator
-      )/ox;
+      )/x;
 
 # ArchiveIterator
 

Modified: spamassassin/trunk/lib/Mail/SpamAssassin/DnsResolver.pm
URL: http://svn.apache.org/viewvc/spamassassin/trunk/lib/Mail/SpamAssassin/DnsResolver.pm?rev=1864400&r1=1864399&r2=1864400&view=diff
==============================================================================
--- spamassassin/trunk/lib/Mail/SpamAssassin/DnsResolver.pm (original)
+++ spamassassin/trunk/lib/Mail/SpamAssassin/DnsResolver.pm Mon Aug  5 00:25:08 2019
@@ -65,8 +65,6 @@ BEGIN {
   }
 }
 
-my $IPV4_ADDRESS = IPV4_ADDRESS;
-
 ###########################################################################
 
 sub new {
@@ -245,7 +243,7 @@ sub available_nameservers {
       local($1,$2);
       /^ \[ (.*) \] : (\d+) \z/xs  or next;
       my($addr,$port) = ($1,$2);
-      if ($addr =~ /^$IPV4_ADDRESS\z/o) {
+      if ($addr =~ IS_IPV4_ADDRESS) {
         push(@filtered_addr_port, $_)  unless $self->{force_ipv6};
       } elsif ($addr =~ /:.*:/) {
         push(@filtered_addr_port, $_)  unless $self->{force_ipv4};
@@ -385,7 +383,7 @@ sub connect_sock {
     $srcaddr = "0.0.0.0";
   } elsif ($self->{force_ipv6}) {
     $srcaddr = "::";
-  } elsif ($ns_addr =~ /^$IPV4_ADDRESS\z/o) {
+  } elsif ($ns_addr =~ IS_IPV4_ADDRESS) {
     $srcaddr = "0.0.0.0";
   } elsif ($ns_addr =~ /:.*:/) {
     $srcaddr = "::";
@@ -535,7 +533,7 @@ sub new_dns_packet {
 
   # construct a PTR query if it looks like an IPv4 address
   if (!defined($type) || $type eq 'PTR') {
-    if ($domain =~ /^$IPV4_ADDRESS$/o) {
+    if ($domain =~ IS_IPV4_ADDRESS) {
       $domain = reverse_ip_address($domain).".in-addr.arpa.";
       $type = 'PTR';
     }
@@ -871,7 +869,7 @@ sub poll_responses {
           if ($id =~ m{^(\d+)/}) {
             my $dnsid = $1;  # the raw DNS packet id
             my @matches =
-              grep(m{^\Q$dnsid\E/}, keys %{$self->{id_to_callback}});
+              grep(m{^\Q$dnsid\E/}o, keys %{$self->{id_to_callback}});
             if (!@matches) {
               info("dns: no likely matching queries for id %s", $dnsid);
             } else {

Modified: spamassassin/trunk/lib/Mail/SpamAssassin/GeoDB.pm
URL: http://svn.apache.org/viewvc/spamassassin/trunk/lib/Mail/SpamAssassin/GeoDB.pm?rev=1864400&r1=1864399&r2=1864400&view=diff
==============================================================================
--- spamassassin/trunk/lib/Mail/SpamAssassin/GeoDB.pm (original)
+++ spamassassin/trunk/lib/Mail/SpamAssassin/GeoDB.pm Mon Aug  5 00:25:08 2019
@@ -118,10 +118,6 @@ my %country_to_continent = (
 'JE'=>'EU','BL'=>'NA','MF'=>'NA','BQ'=>'NA','SS'=>'AF','**'=>'**',
 );
 
-my $IP_PRIVATE = IP_PRIVATE;
-my $IP_ADDRESS = IP_ADDRESS;
-my $IPV4_ADDRESS = IPV4_ADDRESS;
-
 sub new {
   my ($class, $conf) = @_;
   $class = ref($class) || $class;
@@ -500,7 +496,7 @@ sub load_geoip {
   $db->{city} and $dbapi->{city} = sub {
     my $res = {};
     my $city;
-    if ($_[1] =~ /^$IPV4_ADDRESS$/o) {
+    if ($_[1] =~ IS_IPV4_ADDRESS) {
       $city = $_[0]->{db}->{city}->record_by_addr($_[1]);
     } elsif ($_[0]->{db}->{city_v6}) {
       $city = $_[0]->{db}->{city_v6}->country_code_by_addr_v6($_[1]);
@@ -525,7 +521,7 @@ sub load_geoip {
     my $res = {};
     my $country;
     eval {
-      if ($_[1] =~ /^$IPV4_ADDRESS$/o) {
+      if ($_[1] =~ IS_IPV4_ADDRESS) {
         $country = $_[0]->{db}->{country}->country_code_by_addr($_[1]);
       } elsif ($_[0]->{db}->{country_v6}) {
         $country = $_[0]->{db}->{country_v6}->country_code_by_addr_v6($_[1]);
@@ -547,7 +543,7 @@ sub load_geoip {
     my $res = {};
     my $isp;
     eval {
-      if ($_[1] =~ /^$IPV4_ADDRESS$/o) {
+      if ($_[1] =~ IS_IPV4_ADDRESS) {
         $isp = $_[0]->{db}->{isp}->isp_by_addr($_[1]);
       } else {
         # TODO?
@@ -568,7 +564,7 @@ sub load_geoip {
     my $res = {};
     my $asn;
     eval {
-      if ($_[1] =~ /^$IPV4_ADDRESS$/o) {
+      if ($_[1] =~ IS_IPV4_ADDRESS) {
         $asn = $_[0]->{db}->{asn}->isp_by_addr($_[1]);
       } else {
         # TODO?
@@ -622,7 +618,7 @@ sub load_dbfile {
   $db->{country} and $dbapi->{country} = $dbapi->{country_v6} = sub {
     my $res = {};
     my $country;
-    if ($_[1] =~ /^$IPV4_ADDRESS$/o) {
+    if ($_[1] =~ IS_IPV4_ADDRESS) {
       $country = $_[0]->{db}->{country}->inet_atocc($_[1]);
     } else {
       $country = $_[0]->{db}->{country}->inet6_atocc($_[1]);
@@ -663,7 +659,7 @@ sub load_fast {
   $db->{country} and $dbapi->{country} = sub {
     my $res = {};
     my $country;
-    if ($_[1] =~ /^$IPV4_ADDRESS$/o) {
+    if ($_[1] =~ IS_IPV4_ADDRESS) {
       $country = $_[0]->{db}->{country}->inet_atocc($_[1]);
     } else {
       return $res
@@ -696,11 +692,11 @@ sub get_country {
 
   return undef if !defined $ip || $ip !~ /\S/; ## no critic (ProhibitExplicitReturnUndef)
 
-  if ($ip =~ /^$IP_PRIVATE$/o) {
+  if ($ip =~ IS_IP_PRIVATE) {
     return '**';
   }
 
-  if ($ip !~ /^$IP_ADDRESS$/o) {
+  if ($ip !~ IS_IP_ADDRESS) {
     $ip = name_to_ip($ip);
     return 'XX' if !defined $ip;
   }
@@ -766,11 +762,11 @@ sub get_all {
 
   my $all = {};
 
-  if ($ip =~ /^$IP_PRIVATE$/o) {
+  if ($ip =~ IS_IP_PRIVATE) {
     return { 'country' => '**' };
   }
 
-  if ($ip !~ /^$IP_ADDRESS$/o) {
+  if ($ip !~ IS_IP_ADDRESS) {
     $ip = name_to_ip($ip);
     if (!defined $ip) {
       return { 'country' => 'XX' };

Modified: spamassassin/trunk/lib/Mail/SpamAssassin/Message.pm
URL: http://svn.apache.org/viewvc/spamassassin/trunk/lib/Mail/SpamAssassin/Message.pm?rev=1864400&r1=1864399&r2=1864400&view=diff
==============================================================================
--- spamassassin/trunk/lib/Mail/SpamAssassin/Message.pm (original)
+++ spamassassin/trunk/lib/Mail/SpamAssassin/Message.pm Mon Aug  5 00:25:08 2019
@@ -153,7 +153,7 @@ sub new {
   if (ref $message eq 'ARRAY') {
      @message = @{$message};
   }
-  elsif (ref($message) eq 'GLOB' || ref($message) =~ /^IO::/) {
+  elsif (ref($message) eq 'GLOB' || index(ref($message), 'IO::') == 0) {
     if (defined fileno $message) {
 
       # sysread+split avoids a Perl I/O bug (Bug 5985)
@@ -250,7 +250,7 @@ sub new {
   # bug 4363
   # Check to see if we should do CRLF instead of just LF
   # For now, just check the first and last line and do whatever it does
-  if (@message && ($message[0] =~ /\015\012/ || $message[-1] =~ /\015\012/)) {
+  if (@message && (index($message[0], "\015\012") != -1 || index($message[-1], "\015\012") != -1)) {
     $self->{line_ending} = "\015\012";
     dbg("message: line ending changed to CRLF");
   }
@@ -300,7 +300,7 @@ sub new {
         }
       }
 
-      if ($current =~ /^\r?$/) {  # a regular end of a header section
+      if ($current eq "\012" || $current eq "\015\012") {  # a regular end of a header section
 	if ($eof) {
 	  $self->{'missing_head_body_separator'} = 1;
 	} else {
@@ -386,7 +386,7 @@ sub new {
   # either a blank line or the boundary (if defined), insert a blank line
   # to ensure proper parsing - do not consider MIME headers at the beginning of the body
   # to be part of the message headers.
-  if ($self->{'type'} =~ /^multipart\//i && $#message > 0 && $message[0] =~ /\S/)
+  if (index($self->{'type'}, 'multipart/') == 0 && $#message > 0 && $message[0] =~ /\S/)
   {
     if (!defined $boundary || $message[0] !~ /^--\Q$boundary\E/)
     {
@@ -765,7 +765,7 @@ sub parse_body {
     #
     my ($msg, $boundary, $body, $subparse) = @$toparse;
 
-    if ($msg->{'type'} =~ m{^multipart/}i && defined $boundary && $subparse > 0) {
+    if (index($msg->{'type'}, 'multipart/') == 0 && defined $boundary && $subparse > 0) {
       $self->_parse_multipart($toparse);
     }
     else {
@@ -773,7 +773,8 @@ sub parse_body {
       $self->_parse_normal($toparse);
 
       # bug 5041: process message/*, but exclude message/partial content types
-      if ($msg->{'type'} =~ m{^message/(?!partial\z)}i && $subparse > 0)
+      if (index($msg->{'type'}, 'message/') == 0 &&
+          $msg->{'type'} ne 'message/partial' && $subparse > 0)
       {
         # Just decode the part, but we don't need the resulting string here.
         $msg->decode(0);
@@ -789,7 +790,7 @@ sub parse_body {
         # bug 5051, bug 3748: check $msg->{decoded}: sometimes message/* parts
         # have no content, and we get stuck waiting for STDIN, which is bad. :(
 
-        if ($msg->{'type'} =~ m{^message/(?:rfc822|global)\z}i &&
+        if (($msg->{'type'} eq 'message/rfc822' || $msg->{'type'} eq 'message/global') &&
             defined $msg->{'decoded'} && $msg->{'decoded'} ne '')
         {
 	  # Ok, so this part is still semi-recursive, since M::SA::Message
@@ -1058,7 +1059,7 @@ sub _parse_normal {
 
   # multipart sections are required to have a boundary set ...  If this
   # one doesn't, assume it's malformed and revert to text/plain
-  $msg->{'type'} = ($ct[0] !~ m@^multipart/@i || defined $boundary ) ? $ct[0] : 'text/plain';
+  $msg->{'type'} = (index($ct[0], 'multipart/') != 0 || defined $boundary) ? $ct[0] : 'text/plain';
   $msg->{'charset'} = $ct[2];
 
   # attempt to figure out a name for this attachment if there is one ...
@@ -1076,7 +1077,8 @@ sub _parse_normal {
   # ahead and write the part data out to a temp file -- why keep sucking
   # up RAM with something we're not going to use?
   #
-  if ($msg->{'type'} !~ m@^(?:text/(?:plain|html)$|message\b)@) {
+  unless ($msg->{'type'} eq 'text/plain' || $msg->{'type'} eq 'text/html' ||
+          index($msg->{'type'}, 'message/') == 0) {
     my($filepath, $fh);
     eval {
       ($filepath, $fh) = Mail::SpamAssassin::Util::secure_tmpfile();  1;
@@ -1111,7 +1113,7 @@ sub get_mimepart_digests {
   if (!exists $self->{mimepart_digests}) {
     # traverse all parts which are leaves, recursively
     $self->{mimepart_digests} =
-      [ map(sha1_hex($_->decode) . ':' . lc($_->{type}||''),
+      [ map(sha1_hex($_->decode) . ':' . ($_->{type}||''),
             $self->find_parts(qr/^/,1,1)) ];
   }
   return $self->{mimepart_digests};
@@ -1220,7 +1222,7 @@ sub get_decoded_body_text_array {
   $self->{text_decoded} = [ ];
 
   # Find all parts which are leaves
-  my @parts = $self->find_parts(qr/^(?:text|message)\b/i,1);
+  my @parts = $self->find_parts(qr/^(?:text|message)\b/,1);
   return $self->{text_decoded} unless @parts;
 
   # Go through each part

Modified: spamassassin/trunk/lib/Mail/SpamAssassin/Message/Metadata/Received.pm
URL: http://svn.apache.org/viewvc/spamassassin/trunk/lib/Mail/SpamAssassin/Message/Metadata/Received.pm?rev=1864400&r1=1864399&r2=1864400&view=diff
==============================================================================
--- spamassassin/trunk/lib/Mail/SpamAssassin/Message/Metadata/Received.pm (original)
+++ spamassassin/trunk/lib/Mail/SpamAssassin/Message/Metadata/Received.pm Mon Aug  5 00:25:08 2019
@@ -50,6 +50,10 @@ use Mail::SpamAssassin::Dns;
 use Mail::SpamAssassin::PerMsgStatus;
 use Mail::SpamAssassin::Constants qw(:ip);
 
+my $IP_ADDRESS = IP_ADDRESS;
+my $IP_PRIVATE = IP_PRIVATE;
+my $LOCALHOST = LOCALHOST;
+
 # ---------------------------------------------------------------------------
 
 sub parse_received_headers {
@@ -116,10 +120,6 @@ sub parse_received_headers {
     }
   }
 
-  my $IP_ADDRESS = IP_ADDRESS;
-  my $IP_PRIVATE = IP_PRIVATE;
-  my $LOCALHOST = LOCALHOST;
-
   my @hdrs = $msg->get_header('Received');
 
   # Now add the single line headers like X-Originating-IP. (bug 5680)
@@ -335,9 +335,6 @@ sub parse_received_line {
   my $ident = '';
   my $envfrom = undef;
   my $mta_looked_up_dns = 0;
-  my $IP_ADDRESS = IP_ADDRESS;
-  my $IP_PRIVATE = IP_PRIVATE;
-  my $LOCALHOST = LOCALHOST;
   my $auth = '';
 
 # ---------------------------------------------------------------------------
@@ -429,7 +426,7 @@ sub parse_received_line {
     $auth = "GMX ($4 / $3)";
   }
   # Critical Path Messaging Server
-  elsif (/ \(authenticated as /&&/\) by .+ \(\d{1,2}\.\d\.\d{3}(?:\.\d{1,3})?\) \(authenticated as .+\) id /) {
+  elsif (/ \(authenticated as / && /\) by .+ \(\d{1,2}\.\d\.\d{3}(?:\.\d{1,3})?\) \(authenticated as .+\) id /) {
     $auth = 'CriticalPath';
   }
   # Postfix 2.3 and later with "smtpd_sasl_authenticated_header yes"
@@ -803,7 +800,7 @@ sub parse_received_line {
     
     # Received: from [193.220.176.134] by web40310.mail.yahoo.com via HTTP;
     # Wed, 12 Feb 2003 14:22:21 PST
-    if (/ via HTTP$/&&/^\[(${IP_ADDRESS})\] by (\S+) via HTTP$/) {
+    if (/ via HTTP$/ && /^\[(${IP_ADDRESS})\] by (\S+) via HTTP$/) {
       $ip = $1; $by = $2; goto enough;
     }
 
@@ -922,13 +919,13 @@ sub parse_received_line {
 
     # Received: from [129.24.215.125] by ws1-7.us4.outblaze.com with http for
     # _bushisevil_@mail.com; Thu, 13 Feb 2003 15:59:28 -0500
-    if (/ with http for /&&/^\[(${IP_ADDRESS})\] by (\S+) with http for /) {
+    if (/ with http for / && /^\[(${IP_ADDRESS})\] by (\S+) with http for /) {
       $ip = $1; $by = $2; goto enough;
     }
 
     # Received: from snake.corp.yahoo.com(216.145.52.229) by x.x.org via smap (V1.3)
     # id xma093673; Wed, 26 Mar 03 20:43:24 -0600
-    if (/ via smap /&&/^(\S+)\((${IP_ADDRESS})\) by (\S+) via smap /) {
+    if (/ via smap / && /^(\S+)\((${IP_ADDRESS})\) by (\S+) via smap /) {
       $mta_looked_up_dns = 1;
       $rdns = $1; $ip = $2; $by = $3; goto enough;
     }
@@ -943,13 +940,13 @@ sub parse_received_line {
     # Received: from [192.168.0.71] by web01-nyc.clicvu.com (Post.Office MTA
     # v3.5.3 release 223 ID# 0-64039U1000L100S0V35) with SMTP id com for
     # <x...@x.org>; Tue, 25 Mar 2003 11:42:04 -0500
-    if (/ \(Post/&&/^\[(${IP_ADDRESS})\] by (\S+) \(Post/) {
+    if (/ \(Post/ && /^\[(${IP_ADDRESS})\] by (\S+) \(Post/) {
       $ip = $1; $by = $2; goto enough;
     }
 
     # Received: from [127.0.0.1] by euphoria (ArGoSoft Mail Server 
     # Freeware, Version 1.8 (1.8.2.5)); Sat, 8 Feb 2003 09:45:32 +0200
-    if (/ \(ArGoSoft/&&/^\[(${IP_ADDRESS})\] by (\S+) \(ArGoSoft/) {
+    if (/ \(ArGoSoft/ && /^\[(${IP_ADDRESS})\] by (\S+) \(ArGoSoft/) {
       $ip = $1; $by = $2; goto enough;
     }
 
@@ -962,7 +959,7 @@ sub parse_received_line {
 
     # Received: from faerber.muc.de by slarti.muc.de with BSMTP (rsmtp-qm-ot 0.4)
     # for asrg@ietf.org; 7 Mar 2003 21:10:38 -0000
-    if (/ with BSMTP/&&/^\S+ by \S+ with BSMTP/) {
+    if (/ with BSMTP/ && /^\S+ by \S+ with BSMTP/) {
       return 0;	# BSMTP != a TCP/IP handover, ignore it
     }
 

Modified: spamassassin/trunk/lib/Mail/SpamAssassin/Message/Node.pm
URL: http://svn.apache.org/viewvc/spamassassin/trunk/lib/Mail/SpamAssassin/Message/Node.pm?rev=1864400&r1=1864399&r2=1864400&view=diff
==============================================================================
--- spamassassin/trunk/lib/Mail/SpamAssassin/Message/Node.pm (original)
+++ spamassassin/trunk/lib/Mail/SpamAssassin/Message/Node.pm Mon Aug  5 00:25:08 2019
@@ -913,12 +913,12 @@ Delete the specified header (decoded and
 sub delete_header {
   my($self, $hdr) = @_;
 
-  foreach ( grep(/^${hdr}$/i, keys %{$self->{'headers'}}) ) {
+  foreach ( grep(/^${hdr}$/io, keys %{$self->{'headers'}}) ) {
     delete $self->{'headers'}->{$_};
     delete $self->{'raw_headers'}->{$_};
   }
   
-  my @neworder = grep(!/^${hdr}$/i, @{$self->{'header_order'}});
+  my @neworder = grep(!/^${hdr}$/io, @{$self->{'header_order'}});
   $self->{'header_order'} = \@neworder;
 }
 
@@ -984,7 +984,7 @@ sub _decode_header {
     # Bug 6945: some header fields must not be processed for MIME encoding
     # Bug 7249: leave out the Content-*
 
-  } elsif ($header_field_body =~ /=\?/) {  # triage for possible encoded-words
+  } elsif (index($header_field_body, '=?') != -1) {  # triage for possible encoded-words
     local($1,$2,$3,$4);
 
     # Multiple encoded sections must ignore the interim whitespace.

Modified: spamassassin/trunk/lib/Mail/SpamAssassin/PerMsgStatus.pm
URL: http://svn.apache.org/viewvc/spamassassin/trunk/lib/Mail/SpamAssassin/PerMsgStatus.pm?rev=1864400&r1=1864399&r2=1864400&view=diff
==============================================================================
--- spamassassin/trunk/lib/Mail/SpamAssassin/PerMsgStatus.pm (original)
+++ spamassassin/trunk/lib/Mail/SpamAssassin/PerMsgStatus.pm Mon Aug  5 00:25:08 2019
@@ -2280,14 +2280,14 @@ sub _tbirdurire {
 
   # knownscheme regexp looks for either a https?: or ftp: scheme, or www\d*\. or ftp\. prefix, i.e., likely to start a URL
   # schemeless regexp looks for a valid TLD at the end of what may be a FQDN, followed by optional ., optional :portnum, optional /rest_of_uri
-  my $urischemeless = qr/[a-z\d][a-z\d._-]{0,251}\.${tldsRE}\.?(?::\d{1,5})?(?:\/[^$tbirdenddelim]{1,251})?/io;
-  my $uriknownscheme = qr/(?:(?:(?:https?|ftp):(?:\/\/)?)|(?:(?:www\d{0,2}|ftp)\.))[^$tbirdenddelim]{1,251}/io;
-  my $urimailscheme = qr/(?:mailto:)?[^$tbirdenddelimplusat]{1,251}@[^$tbirdenddelimemail]{1,251}/io;
+  my $urischemeless = qr/[a-z\d][a-z\d._-]{0,251}\.${tldsRE}\.?(?::\d{1,5})?(?:\/[^$tbirdenddelim]{1,251})?/i;
+  my $uriknownscheme = qr/(?:(?:(?:https?|ftp):(?:\/\/)?)|(?:(?:www\d{0,2}|ftp)\.))[^$tbirdenddelim]{1,251}/i;
+  my $urimailscheme = qr/(?:mailto:)?[^$tbirdenddelimplusat]{1,251}@[^$tbirdenddelimemail]{1,251}/i;
 
   $self->{tbirdurire} = qr/(?:\b|(?<=$iso2022shift)|(?<=[$tbirdstartdelim]))
                         (?:(?:($uriknownscheme)(?=(?:[$tbirdenddelim]|\z))) |
                         (?:($urimailscheme)(?=(?:[$tbirdenddelimemail]|\z))) |
-                        (?:\b($urischemeless)(?=(?:[$tbirdenddelim]|\z))))/xo;
+                        (?:\b($urischemeless)(?=(?:[$tbirdenddelim]|\z))))/x;
 
   return $self->{tbirdurire};
 }
@@ -2447,7 +2447,7 @@ sub _process_text_uri_list {
         elsif ($uri =~ /^www\d{0,2}\./i) {
           $uri = "http://$uri";
         }
-        elsif ($uri =~ /\@/) {
+        elsif (index($uri, '@') != -1) {
           $uri = "mailto:$uri";
         }
         else {

Modified: spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/ASN.pm
URL: http://svn.apache.org/viewvc/spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/ASN.pm?rev=1864400&r1=1864399&r2=1864400&view=diff
==============================================================================
--- spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/ASN.pm (original)
+++ spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/ASN.pm Mon Aug  5 00:25:08 2019
@@ -128,8 +128,6 @@ our @ISA = qw(Mail::SpamAssassin::Plugin
 
 our $txtdata_can_provide_a_list;
 
-my $IPV4_ADDRESS = IPV4_ADDRESS;
-
 sub new {
   my ($class, $mailsa) = @_;
   $class = ref($class) || $class;
@@ -394,7 +392,7 @@ sub parsed_metadata {
 
   dbg("asn: using DNS for lookups");
   my $lookup_zone;
-  if ($ip =~ /^$IPV4_ADDRESS$/o) {
+  if ($ip =~ IS_IPV4_ADDRESS) {
     if (!defined $conf->{asnlookups}) {
       dbg("asn: asn_lookup for IPv4 not defined, skipping");
       return;

Modified: spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/AskDNS.pm
URL: http://svn.apache.org/viewvc/spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/AskDNS.pm?rev=1864400&r1=1864399&r2=1864400&view=diff
==============================================================================
--- spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/AskDNS.pm (original)
+++ spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/AskDNS.pm Mon Aug  5 00:25:08 2019
@@ -212,8 +212,6 @@ our %rcode_value = (  # https://www.iana
 
 our $txtdata_can_provide_a_list;
 
-my $IP_ADDRESS = IP_ADDRESS;
-
 sub new {
   my($class,$sa_main) = @_;
 

Modified: spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/Bayes.pm
URL: http://svn.apache.org/viewvc/spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/Bayes.pm?rev=1864400&r1=1864399&r2=1864400&view=diff
==============================================================================
--- spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/Bayes.pm (original)
+++ spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/Bayes.pm Mon Aug  5 00:25:08 2019
@@ -131,7 +131,7 @@ our $IGNORED_HDRS = qr{(?: (?:X-)?Sender
   | X-Gnus-Mail-Source
   | Xref
 
-)}x;
+)}ix;
 
 # Note only the presence of these headers, in order to reduce the
 # hapaxen they generate.
@@ -1172,7 +1172,7 @@ sub _tokenize_line {
     # tokens, so the SQL BayesStore returns undef.  I really want a way
     # of optimizing that out, but I haven't come up with anything yet.
     #
-    next if ( defined $magic_re && $token =~ /$magic_re/ );
+    next if ( defined $magic_re && $token =~ /$magic_re/o );
 
     # *do* keep 3-byte tokens; there's some solid signs in there
     my $len = length($token);

Modified: spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/BodyEval.pm
URL: http://svn.apache.org/viewvc/spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/BodyEval.pm?rev=1864400&r1=1864399&r2=1864400&view=diff
==============================================================================
--- spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/BodyEval.pm (original)
+++ spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/BodyEval.pm Mon Aug  5 00:25:08 2019
@@ -77,7 +77,7 @@ sub _multipart_alternative_difference {
   my $msg = $pms->{msg};
 
   # Find all multipart/alternative parts in the message
-  my @ma = $msg->find_parts(qr@^multipart/alternative\b@i);
+  my @ma = $msg->find_parts(qr@^multipart/alternative\b@);
 
   # If there are no multipart/alternative sections, skip this test.
   return if (!@ma);
@@ -100,7 +100,7 @@ sub _multipart_alternative_difference {
     my %text;
 
     # limit our search to text-based parts
-    my @txt = $part->find_parts(qr@^text\b@i);
+    my @txt = $part->find_parts(qr@^text\b@);
     foreach my $text (@txt) {
       # we only care about the rendered version of the part
       my ($type, $rnd) = $text->rendered();
@@ -237,7 +237,7 @@ sub _check_stock_info {
   $pms->{stock_info} = 0;
 
   # Find all multipart/alternative parts in the message
-  my @parts = $pms->{msg}->find_parts(qr@^text/plain$@i);
+  my @parts = $pms->{msg}->find_parts(qr@^text/plain$@);
   return if (!@parts);
 
   # Go through each of the multipart parts

Modified: spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/DNSEval.pm
URL: http://svn.apache.org/viewvc/spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/DNSEval.pm?rev=1864400&r1=1864399&r2=1864400&view=diff
==============================================================================
--- spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/DNSEval.pm (original)
+++ spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/DNSEval.pm Mon Aug  5 00:25:08 2019
@@ -55,7 +55,6 @@ use re 'taint';
 our @ISA = qw(Mail::SpamAssassin::Plugin);
 
 my $IP_ADDRESS = IP_ADDRESS;
-my $IP_PRIVATE = IP_PRIVATE;
 
 # constructor: register the eval rule
 sub new {
@@ -211,7 +210,7 @@ sub ip_list_uniq_and_strip_private {
     next unless $ip;
     next if exists $seen{$ip};
     $seen{$ip} = 1;
-    next if $ip =~ /^$IP_PRIVATE$/o;
+    next if $ip =~ IS_IP_PRIVATE;
     push(@ips, $ip);
   }
   return @ips;
@@ -421,7 +420,7 @@ sub check_rbl_headers {
     } else {
       my $host = $pms->get($rbl_headers);
       chomp($host);
-      if($host =~ /^$IP_ADDRESS$/ ) {
+      if ($host =~ IS_IP_ADDRESS) {
         return if ($conf->{tflags}->{$rule}||'') =~ /\bdomains_only\b/;
         $host = reverse_ip_address($host);
       } else {
@@ -562,7 +561,7 @@ sub check_rbl_rcvd {
   foreach my $host ( @udnsrcvd ) {
     if((defined $host) and ($host ne "")) {
       chomp($host);
-      if($host =~ /^$IP_ADDRESS$/ ) {
+      if ($host =~ IS_IP_ADDRESS) {
         next if ($pms->{conf}->{tflags}->{$rule}||'') =~ /\bdomains_only\b/;
         $host = reverse_ip_address($host);
       } else {
@@ -614,7 +613,7 @@ sub _check_rbl_addresses {
   return unless scalar keys %hosts;
 
   for my $host (keys %hosts) {
-    if ($host =~ /^$IP_ADDRESS$/) {
+    if ($host =~ IS_IP_ADDRESS) {
       next if ($pms->{conf}->{tflags}->{$rule}||'') =~ /\bdomains_only\b/;
       $host = reverse_ip_address($host);
     } else {

Modified: spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/FreeMail.pm
URL: http://svn.apache.org/viewvc/spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/FreeMail.pm?rev=1864400&r1=1864399&r2=1864400&view=diff
==============================================================================
--- spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/FreeMail.pm (original)
+++ spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/FreeMail.pm Mon Aug  5 00:25:08 2019
@@ -111,6 +111,7 @@ header FREEMAIL_BODY eval:check_freemail
 
 use Mail::SpamAssassin::Plugin;
 use Mail::SpamAssassin::PerMsgStatus;
+use Mail::SpamAssassin::Util qw(compile_regexp);
 
 our @ISA = qw(Mail::SpamAssassin::Plugin);
 
@@ -335,7 +336,7 @@ sub _is_freemail {
     foreach my $list ('whitelist_auth','def_whitelist_auth') {
         if ($pms->{conf}->{"freemail_import_$list"}) {
             foreach my $regexp (values %{$pms->{conf}->{$list}}) {
-                if ($email =~ /$regexp/) {
+                if ($email =~ /$regexp/o) {
                     dbg("whitelisted email, $list: $email");
                     return 0;
                 }
@@ -364,7 +365,7 @@ sub _parse_body {
         my $parsed = $pms->get_uri_detail_list();
         while (my($uri, $info) = each %{$parsed}) {
             if (defined $info->{types}->{a} and not defined $info->{types}->{parsed}) {
-                if ($uri =~ /^(?:(?i)mailto):$self->{email_regex}/) {
+                if ($uri =~ /^(?:(?i)mailto):$self->{email_regex}/o) {
                     my $email = lc($1);
                     push(@body_emails, $email) unless defined $seen{$email};
                     $seen{$email} = 1;
@@ -453,11 +454,12 @@ sub check_freemail_header {
 
     my $re;
     if (defined $regex) {
-        $re = eval { qr/$regex/; };
-        if ($@) {
-            warn("invalid regex: $@");
+        my ($rec, $err) = compile_regexp($regex, 0);
+        if (!$rec) {
+            warn "freemail: invalid regexp for $rulename '$regex': $err\n";
             return 0;
         }
+        $re = $rec;
     }
 
     my @emails = map (lc, $pms->{main}->find_all_addrs_in_line ($pms->get($header)));
@@ -471,7 +473,7 @@ sub check_freemail_header {
     foreach my $email (@emails) {    
         if ($self->_is_freemail($email, $pms)) {
             if (defined $re) {
-                next unless $email =~ $re;
+                next unless $email =~ /$re/o;
                 dbg("HIT! $email is freemail and matches regex");
             }
             else {
@@ -497,16 +499,17 @@ sub check_freemail_body {
 
     my $re;
     if (defined $regex) {
-        $re = eval { qr/$regex/; };
-        if ($@) {
-            warn("invalid regex: $@");
+        my ($rec, $err) = compile_regexp($regex, 0);
+        if (!$rec) {
+            warn "freemail: invalid regexp for $rulename '$regex': $err\n";
             return 0;
         }
+        $re = $rec;
     }
 
     if (defined $re) {
         foreach my $email (keys %{$pms->{freemail_cache}{body}}) {
-            if ($email =~ $re) {
+            if ($email =~ /$re/o) {
                 dbg("HIT! email from body is freemail and matches regex: $email");
                 $self->_got_hit($pms, $email, "Email from body is freemail");
                 return 0;
@@ -533,11 +536,12 @@ sub check_freemail_from {
 
     my $re;
     if (defined $regex) {
-        $re = eval { qr/$regex/; };
-        if ($@ or not defined $re) {
-            warn("invalid regex: $@");
+        my ($rec, $err) = compile_regexp($regex, 0);
+        if (!$rec) {
+            warn "freemail: invalid regexp for $rulename '$regex': $err\n";
             return 0;
         }
+        $re = $rec;
     }
 
     my %from_addrs = map { lc($_) => 1 } ($pms->all_from_addrs());
@@ -553,7 +557,7 @@ sub check_freemail_from {
     foreach my $email (keys %from_addrs) {
         next unless $self->_is_freemail($email, $pms);
         if (defined $re) {
-            next unless $email =~ $re;
+            next unless $email =~ /$re/o;
             dbg("HIT! $email is freemail and matches regex");
         }
         else {

Modified: spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/HTTPSMismatch.pm
URL: http://svn.apache.org/viewvc/spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/HTTPSMismatch.pm?rev=1864400&r1=1864399&r2=1864400&view=diff
==============================================================================
--- spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/HTTPSMismatch.pm (original)
+++ spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/HTTPSMismatch.pm Mon Aug  5 00:25:08 2019
@@ -49,8 +49,6 @@ sub new {
 sub check_https_http_mismatch {
   my ($self, $permsgstatus, undef, $minanchors, $maxanchors) = @_;
 
-  my $IP_ADDRESS = IP_ADDRESS;
-
   $minanchors ||= 1;
 
   if (!exists $permsgstatus->{chhm_hit}) {
@@ -65,10 +63,10 @@ sub check_https_http_mismatch {
       next unless (exists $v->{anchor_text} && @{$v->{anchor_text}});
 
       my $uri;
-      if ($k =~ m@^https?://([^/:]+)@i) {
+      if ($k =~ m@^https?://([^/:?#]+)@i) {
         $uri = $1;
         # Skip IPs since there's another rule to catch that already
-        if ($uri =~ /^$IP_ADDRESS+$/) {
+        if ($uri =~ IS_IP_ADDRESS) {
           undef $uri;
           next;
         } 
@@ -82,12 +80,12 @@ sub check_https_http_mismatch {
       $permsgstatus->{chhm_anchors}++ if exists $v->{anchor_text};
 
       foreach (@{$v->{anchor_text}}) {
-        if (m@https://([^/:]+)@i) {
+        if (m@https://([^/:?#]+)@i) {
           my $https = $1;
 
 	  # want to compare whole hostnames instead of domains?
 	  # comment this next section to the blank line.
-          if ($https !~ /^$IP_ADDRESS+$/) {
+          if ($https !~ IS_IP_ADDRESS) {
 	    $https = $self->{main}->{registryboundaries}->trim_domain($https);
             undef $https unless ($self->{main}->{registryboundaries}->is_domain_valid($https));
           }

Modified: spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/HeaderEval.pm
URL: http://svn.apache.org/viewvc/spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/HeaderEval.pm?rev=1864400&r1=1864399&r2=1864400&view=diff
==============================================================================
--- spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/HeaderEval.pm (original)
+++ spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/HeaderEval.pm Mon Aug  5 00:25:08 2019
@@ -32,6 +32,8 @@ use Mail::SpamAssassin::Constants qw(:sa
 
 our @ISA = qw(Mail::SpamAssassin::Plugin);
 
+my $IP_ADDRESS = IP_ADDRESS;
+
 # constructor: register the eval rule
 sub new {
   my $class = shift;
@@ -347,7 +349,6 @@ sub _check_for_forged_hotmail_received_h
   return if $self->check_for_msn_groups_headers($pms);
 
   my $ip = $pms->get('X-Originating-Ip',undef);
-  my $IP_ADDRESS = IP_ADDRESS;
   my $orig = $pms->get('X-OriginatorOrg',undef);
   my $ORIGINATOR = 'hotmail.com';
 
@@ -476,7 +477,6 @@ sub check_for_forged_eudoramail_received
   $rcvd =~ s/\s+/ /gs;		# just spaces, simplify the regexp
 
   my $ip = $pms->get('X-Sender-Ip',undef);
-  my $IP_ADDRESS = IP_ADDRESS;
   if (defined $ip && $ip =~ /$IP_ADDRESS/) { $ip = 1; } else { $ip = 0; }
 
   # Eudoramail formats its received headers like this:
@@ -529,7 +529,6 @@ sub check_for_forged_yahoo_received_head
   if ($rcvd =~ /by web\S+\.mail\S*\.yahoo\.com via HTTP/) { return 0; }
   if ($rcvd =~ /by sonic\S+\.consmr\.mail\S*\.yahoo\.com with HTTP/) { return 0; }
   if ($rcvd =~ /by smtp\S+\.yahoo\.com with SMTP/) { return 0; }
-  my $IP_ADDRESS = IP_ADDRESS;
   if ($rcvd =~
       /from \[$IP_ADDRESS\] by \S+\.(?:groups|scd|dcn)\.yahoo\.com with NNFMP/) {
     return 0;
@@ -565,7 +564,6 @@ sub check_for_forged_juno_received_heade
   my $xorig = $pms->get('X-Originating-IP');
   my $xmailer = $pms->get('X-Mailer');
   my $rcvd = $pms->get('Received');
-  my $IP_ADDRESS = IP_ADDRESS;
 
   if ($xorig ne '') {
     # New style Juno has no X-Originating-IP header, and other changes

Modified: spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/MIMEEval.pm
URL: http://svn.apache.org/viewvc/spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/MIMEEval.pm?rev=1864400&r1=1864399&r2=1864400&view=diff
==============================================================================
--- spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/MIMEEval.pm (original)
+++ spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/MIMEEval.pm Mon Aug  5 00:25:08 2019
@@ -629,7 +629,7 @@ sub get_charset_from_ct_line {
 sub check_ma_non_text {
   my($self, $pms) = @_;
 
-  foreach my $map ($pms->{msg}->find_parts(qr@^multipart/alternative$@i)) {
+  foreach my $map ($pms->{msg}->find_parts(qr@^multipart/alternative$@)) {
     foreach my $p ($map->find_parts(qr/./, 1, 0)) {
       next if (lc $p->{'type'} eq 'multipart/related');
       next if (lc $p->{'type'} eq 'application/rtf');

Modified: spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/RelayEval.pm
URL: http://svn.apache.org/viewvc/spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/RelayEval.pm?rev=1864400&r1=1864399&r2=1864400&view=diff
==============================================================================
--- spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/RelayEval.pm (original)
+++ spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/RelayEval.pm Mon Aug  5 00:25:08 2019
@@ -28,6 +28,8 @@ use re 'taint';
 
 our @ISA = qw(Mail::SpamAssassin::Plugin);
 
+my $IPV4_ADDRESS = IPV4_ADDRESS;
+
 # constructor: register the eval rule
 sub new {
   my $class = shift;
@@ -84,12 +86,10 @@ sub check_for_numeric_helo {
   my $rcvd = $pms->{relays_untrusted_str};
 
   if ($rcvd) {
-    my $IP_ADDRESS = IPV4_ADDRESS;
-    my $IP_PRIVATE = IP_PRIVATE;
     local $1;
     # no re "strict";  # since perl 5.21.8: Ranges of ASCII printables...
-    if ($rcvd =~ /\bhelo=($IP_ADDRESS)(?=[\000-\040,;\[()<>]|\z)/i  # Bug 5878
-        && $1 !~ /$IP_PRIVATE/) {
+    if ($rcvd =~ /\bhelo=($IPV4_ADDRESS)(?=[\000-\040,;\[()<>]|\z)/i  # Bug 5878
+        && $1 !~ IS_IP_PRIVATE) {
       return 1;
     }
   }
@@ -108,23 +108,21 @@ sub check_for_illegal_ip {
 # due to bug in pure IPv6 address regular expression
 sub helo_ip_mismatch {
   my ($self, $pms) = @_;
-  my $IP_ADDRESS = IPV4_ADDRESS;
-  my $IP_PRIVATE = IP_PRIVATE;
 
   for my $relay (@{$pms->{relays_untrusted}}) {
     # is HELO usable?
-    next unless ($relay->{helo} =~ m/^$IP_ADDRESS$/ &&
-		 $relay->{helo} !~ /$IP_PRIVATE/);
+    next unless ($relay->{helo} =~ IS_IPV4_ADDRESS &&
+		 $relay->{helo} !~ IS_IP_PRIVATE);
     # compare HELO with IP
-    return 1 if ($relay->{ip} =~ m/^$IP_ADDRESS$/ &&
-		 $relay->{ip} !~ m/$IP_PRIVATE/ &&
+    return 1 if ($relay->{ip} =~ IS_IPV4_ADDRESS &&
+		 $relay->{ip} !~ IS_IP_PRIVATE &&
 		 $relay->{helo} ne $relay->{ip} &&
 		 # different IP is okay if in same /24
 		 $relay->{helo} =~ /^(\d+\.\d+\.\d+\.)/ &&
 		 index($relay->{ip}, $1) != 0);
   }
 
-  0;
+  return 0;
 }
 
 ###########################################################################
@@ -346,7 +344,7 @@ sub _check_for_forged_received {
 	# allow private IP addrs here, could be a legit screwup
 	if ($hclassb && $fclassb && 
 		$hclassb ne $fclassb &&
-		!($hlo =~ /$IP_PRIVATE/o))
+		$hlo !~ IS_IP_PRIVATE)
 	{
 	  dbg2("eval: forged-HELO: massive mismatch on IP-addr HELO: '$hlo' != '$fip'");
 	  $pms->{mismatch_ip_helo}++;

Modified: spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/URIDNSBL.pm
URL: http://svn.apache.org/viewvc/spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/URIDNSBL.pm?rev=1864400&r1=1864399&r2=1864400&view=diff
==============================================================================
--- spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/URIDNSBL.pm (original)
+++ spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/URIDNSBL.pm Mon Aug  5 00:25:08 2019
@@ -309,9 +309,6 @@ our @ISA = qw(Mail::SpamAssassin::Plugin
 
 use constant LOG_COMPLETION_TIMES => 0;
 
-my $IPV4_ADDRESS = IPV4_ADDRESS;
-my $IP_PRIVATE = IP_PRIVATE;
-
 # constructor
 sub new {
   my $class = shift;
@@ -521,7 +518,7 @@ sub parse_and_canonicalize_subtest {
         # ok, already a decimal number
       } elsif (/^0x[0-9a-zA-Z]{1,8}\z/) {
         $_ = hex($_);  # hex -> number
-      } elsif (/^$IPV4_ADDRESS\z/o) {
+      } elsif ($_ =~ IS_IPV4_ADDRESS) {
         $_ = Mail::SpamAssassin::Util::my_inet_aton($_);  # quad-dot -> number
         $any_quad_dot = 1;
       } else {
@@ -840,7 +837,7 @@ sub query_hosts_or_domains {
     # IPv4 look-a-like / IPv6 address literal?
     if ($host =~ /^\d+\.\d+\.\d+\.\d+$/ || $host =~ /^\[/) {
       # only look up the IPv4 if it is public and valid
-      if ($host =~ /^$IPV4_ADDRESS$/o && $host !~ /^$IP_PRIVATE$/o) {
+      if ($host =~ IS_IPV4_ADDRESS && $host !~ IS_IP_PRIVATE) {
         # Use IP in RHSBL lookups
         $domain = $host;
       } else {
@@ -927,7 +924,7 @@ sub complete_ns_lookup {
       # misconfigure. Bind doesn't even allow that..
       if ($nsmatch =~ /^\d+\.\d+\.\d+\.\d+$/ || index($nsmatch, ':') >= 0) {
 	# only look up the IP if it is public and valid
-	if ($nsmatch =~ /^$IPV4_ADDRESS$/o && $nsmatch !~ /^$IP_PRIVATE$/o) {
+	if ($nsmatch =~ IS_IPV4_ADDRESS && $nsmatch !~ IS_IP_PRIVATE) {
           # Use IP in RHSBL lookups
           #$nsrhblstr = $nsmatch; # already set
         } else {
@@ -1070,7 +1067,7 @@ sub complete_dnsbl_lookup {
       # Net::DNS::RR::A::address() is available since Net::DNS 0.69
       $rdatastr = $rr->UNIVERSAL::can('address') ? $rr->address
                                                  : $rr->rdatastr;
-      if ($rdatastr =~ /^$IPV4_ADDRESS$/o) {
+      if ($rdatastr =~ IS_IPV4_ADDRESS) {
         $rdatanum = Mail::SpamAssassin::Util::my_inet_aton($rdatastr);
       }
     } elsif ($rr_type eq 'TXT') {

Modified: spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/URIDetail.pm
URL: http://svn.apache.org/viewvc/spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/URIDetail.pm?rev=1864400&r1=1864399&r2=1864400&view=diff
==============================================================================
--- spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/URIDetail.pm (original)
+++ spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/URIDetail.pm Mon Aug  5 00:25:08 2019
@@ -32,7 +32,7 @@ rules apply to all URIs found in the mes
 
 The format for defining a rule is as follows:
 
-  uri_detail SYMBOLIC_TEST_NAME key1 =~ /value1/  key2 !~ /value2/ ...
+  uri_detail SYMBOLIC_TEST_NAME key1 =~ /value1/i  key2 !~ /value2/ ...
 
 Supported keys are:
 

Modified: spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/URILocalBL.pm
URL: http://svn.apache.org/viewvc/spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/URILocalBL.pm?rev=1864400&r1=1864399&r2=1864400&view=diff
==============================================================================
--- spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/URILocalBL.pm (original)
+++ spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/URILocalBL.pm Mon Aug  5 00:25:08 2019
@@ -373,7 +373,7 @@ sub check_uri_local_bl {
         dbg("excluded $host, domain $domain matches");
         next;
       }
-      elsif ($host =~ /^$IP_ADDRESS$/o) {
+      elsif ($host =~ IS_IP_ADDRESS) {
         if ($self->_check_host($pms, $rulename, $host, [$host])) {
           # if hit, rule is done
           return 0;

Modified: spamassassin/trunk/lib/Mail/SpamAssassin/RegistryBoundaries.pm
URL: http://svn.apache.org/viewvc/spamassassin/trunk/lib/Mail/SpamAssassin/RegistryBoundaries.pm?rev=1864400&r1=1864399&r2=1864400&view=diff
==============================================================================
--- spamassassin/trunk/lib/Mail/SpamAssassin/RegistryBoundaries.pm (original)
+++ spamassassin/trunk/lib/Mail/SpamAssassin/RegistryBoundaries.pm Mon Aug  5 00:25:08 2019
@@ -36,8 +36,6 @@ use Mail::SpamAssassin::Logger;
 use Mail::SpamAssassin::Util qw(idn_to_ascii is_fqdn_valid);
 use Mail::SpamAssassin::Constants qw(:ip);
 
-my $IP_ADDRESS = IP_ADDRESS;
-
 # called from SpamAssassin->init() to create $self->{util_rb}
 sub new {
   my $class = shift;
@@ -255,7 +253,7 @@ sub uri_to_domain {
   my $domain = $host;
 
   # keep IPs intact
-  if ($host !~ /^$IP_ADDRESS$/) {
+  if ($host !~ IS_IP_ADDRESS) {
     # check that it's a valid hostname/fqdn
     return unless is_fqdn_valid($host, 1);
     # ignore invalid TLDs

Modified: spamassassin/trunk/lib/Mail/SpamAssassin/Util.pm
URL: http://svn.apache.org/viewvc/spamassassin/trunk/lib/Mail/SpamAssassin/Util.pm?rev=1864400&r1=1864399&r2=1864400&view=diff
==============================================================================
--- spamassassin/trunk/lib/Mail/SpamAssassin/Util.pm (original)
+++ spamassassin/trunk/lib/Mail/SpamAssassin/Util.pm Mon Aug  5 00:25:08 2019
@@ -79,7 +79,7 @@ use POSIX qw(:sys_wait_h WIFEXITED WIFSI
 ###########################################################################
 
 use constant HAS_MIME_BASE64 => eval { require MIME::Base64; };
-use constant RUNNING_ON_WINDOWS => ($^O =~ /^(?:mswin|dos|os2)/oi);
+use constant RUNNING_ON_WINDOWS => ($^O =~ /^(?:mswin|dos|os2)/i);
 
 # These are only defined as stubs on Windows (see bugs 6798 and 6470).
 BEGIN {
@@ -115,7 +115,7 @@ BEGIN {
   no bytes;  # make sure there is no 'use bytes' in effect
   my $dot_chars = "\x{2024}\x{3002}\x{FF0E}\x{FF61}\x{FE52}";  # \x{002E}
   my $dot_bytes = join('|', split(//,$dot_chars));  utf8::encode($dot_bytes);
-  $ALT_FULLSTOP_UTF8_RE = qr/$dot_bytes/so;
+  $ALT_FULLSTOP_UTF8_RE = qr/$dot_bytes/s;
 }
 
 ###########################################################################
@@ -275,7 +275,7 @@ sub untaint_file_path {
   # Also return '' if input is '', as it is a safe path.
   # Bug 7264: allow also parenthesis, e.g. "C:\Program Files (x86)"
   my $chars = '-_A-Za-z0-9.%=+,/:()\\@\\xA0-\\xFF\\\\';
-  my $re = qr{^\s*([$chars][${chars}~ ]*)\z}o;
+  my $re = qr{^\s*([$chars][${chars}~ ]*)\z};
 
   if ($path =~ $re) {
     $path = $1;
@@ -377,8 +377,8 @@ sub taint_var {
 ###########################################################################
 
 # Check for full hostname / FQDN / DNS name validity.  IP addresses must be
-# validated with other functions like $IP_ADDRESS.  Does not check for valid
-# TLD, use $self->{main}->{registryboundaries}->is_domain_valid()
+# validated with other functions like Constants::IP_ADDRESS.  Does not check
+# for valid TLD, use $self->{main}->{registryboundaries}->is_domain_valid()
 # additionally for that.  If $is_ascii given and true, skip idn_to_ascii()
 # conversion.
 sub is_fqdn_valid {
@@ -490,7 +490,7 @@ sub idn_to_ascii {
     # following characters MUST be recognized as dots: U+002E (full stop),
     # U+3002 (ideographic full stop), U+FF0E (fullwidth full stop),
     # U+FF61 (halfwidth ideographic full stop).
-    if ($s =~ s/$ALT_FULLSTOP_UTF8_RE/./gso) {
+    if ($s =~ s/$ALT_FULLSTOP_UTF8_RE/./gs) {
       dbg("util: idn_to_ascii: alternative dots normalized: '%s' -> '%s'",
            $_[0], $s);
     }
@@ -996,11 +996,11 @@ sub extract_ipv4_addr_from_string {
   return unless defined($str);
 
   if ($str =~ /\b(
-			(?:1\d\d|2[0-4]\d|25[0-5]|[1-9]\d|\d)\.
-			(?:1\d\d|2[0-4]\d|25[0-5]|[1-9]\d|\d)\.
-			(?:1\d\d|2[0-4]\d|25[0-5]|[1-9]\d|\d)\.
-			(?:1\d\d|2[0-4]\d|25[0-5]|[1-9]\d|\d)
-		      )\b/ix)
+                       (?:1\d\d|2[0-4]\d|25[0-5]|[1-9]\d|\d)\.
+                       (?:1\d\d|2[0-4]\d|25[0-5]|[1-9]\d|\d)\.
+                       (?:1\d\d|2[0-4]\d|25[0-5]|[1-9]\d|\d)\.
+                       (?:1\d\d|2[0-4]\d|25[0-5]|[1-9]\d|\d)
+                     )\b/ix)
   {
     if (defined $1) { return $1; }
   }
@@ -1035,7 +1035,7 @@ sub extract_ipv4_addr_from_string {
     return $fq_hostname if defined($fq_hostname);
 
     $fq_hostname = hostname();
-    if ($fq_hostname !~ /\./) { # hostname doesn't contain a dot, so it can't be a FQDN
+    if (index($fq_hostname, '.') == -1) { # hostname doesn't contain a dot, so it can't be a FQDN
       my @names = grep(/^\Q${fq_hostname}.\E/o,                         # grep only FQDNs
                     map { split } (gethostbyname($fq_hostname))[0 .. 1] # from all aliases
                   );
@@ -1954,8 +1954,8 @@ sub compile_regexp {
   local($1);
 
   # Do not allow already compiled regexes or other funky refs
-  if (ref($re)) {
-    return (undef, 'ref passed');
+  if (ref($re) ne '') {
+    return (undef, 'ref passed: '.ref($re));
   }
 
   # try stripping by default

Modified: spamassassin/trunk/t/all_modules.t
URL: http://svn.apache.org/viewvc/spamassassin/trunk/t/all_modules.t?rev=1864400&r1=1864399&r2=1864400&view=diff
==============================================================================
--- spamassassin/trunk/t/all_modules.t (original)
+++ spamassassin/trunk/t/all_modules.t Mon Aug  5 00:25:08 2019
@@ -83,7 +83,8 @@ use_bayes 1
             );
 
 if (conf_bool('run_net_tests')) {
-    sarun ("-D -t < data/nice/001 2>&1", \&patterns_run_cb);
+    # sometimes trips on URIBL_BLOCKED, ignore..
+    sarun ("-D -t < data/nice/001 2>&1 | grep -v dns_block_rule", \&patterns_run_cb);
     ok_all_patterns();
 } else {
     sarun ("-D -L -t < data/nice/001 2>&1", \&patterns_run_cb);