--- Config.pm.old	2003-07-30 17:55:18.000000000 +0100
+++ Config.pm	2003-07-30 18:30:44.000000000 +0100
@@ -1142,6 +1142,33 @@
 sub RuleToRegexp {
   my($rule) = @_;
 
+  # If the rule starts with / but doesn't end in / then it is a filename
+  # which contains a list of regexps (which could in turn include more
+  # filenames.
+  if ($rule =~ m#^/.*[^/]$#) {
+    # $rule is a filename.
+    my($file, $line, @result);
+    $file = new FileHandle;
+    $file->open("<$rule")
+      or MailScanner::Log::DieLog("Could not open ruleset's rule list file %s, %s", $rule, $!);
+    flock($file, $LOCK_SH);
+
+    MailScanner::Log::DebugLog("Reading ruleset's rule list file %s", $rule);
+
+    while(defined($line=<$file>)) {
+      chomp $line;
+      $line =~ s/#.*$//;
+      $line =~ s/^\s+//;
+      $line =~ s/\s+$//;
+      next if $line =~ /^$/;
+      push @result, RuleToRegexp($line);
+    }
+    # Unlock and close rules file
+    flock($file, $LOCK_UN);
+    $file->close();
+    return(@result);
+  }
+
   # Handle entirely numeric strings as netblocks (and allow IPv6 addresses!)
   if ($rule =~ /^[.:\dabcdef]+$/) {
     # Replace . with \.
@@ -1263,41 +1290,48 @@
       next;
     }
 
-    # Convert the rule into a regexp.
-    # Pass it the keyword so it can set the default value if there is one.
-    ($ruletype, $regexp) = RuleToRegexp($rule);
+    # Substitute %% variables
+    $value =~ s/\%([^%]+)\%/$PercentVars{lc($1)}/g;
 
     # Syntax check the value
     #print STDERR "Config: $keyword has rule value " . $File{$keyword} .
     #             " = " . $values{$value} . "\n";
-    
-    # Substitute %% variables
-    $value =~ s/\%([^%]+)\%/$PercentVars{lc($1)}/g;
-
     # Is it a valid value?
     my $internalvalue = undef;
     $internalvalue = InternalDataValue($rulesettype, $value, %values);
-    # 0 might be a valid value!
-    if (defined $internalvalue || $rulesettype eq 'other') {
-      # Update the default value if this is it
-      #print STDERR "Ruleset: Is \"$regexp\" the default rule?\n";
-      if ($regexp eq $DefaultRegexp) {
-        # Don't store it in the main ruleset as it will always match,
-        # whereas we want it to be used only if nothing else matches.
-        #print STDERR "Ruleset: Storing Defaults($keyword) = $internalvalue\n";
-        $Defaults{$keyword} = $internalvalue;
-        next;
+
+    # Convert the rule into a regexp.
+    # Pass it the keyword so it can set the default value if there is one.
+    #($ruletype, $regexp) = RuleToRegexp($rule);
+    my @ruledata;
+    @ruledata = RuleToRegexp($rule);
+
+    while(@ruledata) {
+      $ruletype = shift @ruledata;
+      $regexp   = shift @ruledata;
+
+      # 0 might be a valid value!
+      if (defined $internalvalue || $rulesettype eq 'other') {
+        # Update the default value if this is it
+        #print STDERR "Ruleset: Is \"$regexp\" the default rule?\n";
+        if ($regexp eq $DefaultRegexp) {
+          # Don't store it in the main ruleset as it will always match,
+          # whereas we want it to be used only if nothing else matches.
+          #print STDERR "Ruleset: Storing Defaults($keyword) = $internalvalue\n";
+          $Defaults{$keyword} = $internalvalue;
+          next;
+        }
+        # It is a valid value, so use it and store it
+        my $record = join("\0", $fromto, $ruletype, $regexp, $internalvalue);
+        push @{$RuleScalars{$keyword}}, $record;
+        #print "Storing data: for $keyword $record\n";
+        #print "Storing data: " . join(',',@{$RuleScalars{$keyword}}) . "\n";
+      } else {
+        # It is an invalid value
+        MailScanner::Log::WarnLog("Syntax error in line %d of ruleset file " .
+          "%s for keyword %s", $linecounter, $rulesfilename, $keyword);
+        $errors = 1;
       }
-      # It is a valid value, so use it and store it
-      my $record = join("\0", $fromto, $ruletype, $regexp, $internalvalue);
-      push @{$RuleScalars{$keyword}}, $record;
-      #print "Storing data: for $keyword $record\n";
-      #print "Storing data: " . join(',',@{$RuleScalars{$keyword}}) . "\n";
-    } else {
-      # It is an invalid value
-      MailScanner::Log::WarnLog("Syntax error in line %d of ruleset file " .
-        "%s for keyword %s", $linecounter, $rulesfilename, $keyword);
-      $errors = 1;
     }
   }
 