--- SweepContent.pm.old	2004-05-22 13:30:16.000000000 +0100
+++ SweepContent.pm	2004-05-27 21:21:34.000000000 +0100
@@ -81,8 +81,15 @@
 
   while(($id, $message) = each %{$batch->{messages}}) {
     next if $message->{deleted};
+
     $ent = $message->{entity};
 
+    #
+    # Do the partial and external checks even if they don't want
+    # dangerous content scanning, as they directly affect our ability
+    # to scan for viruses.
+    #
+
     # Search for multipart/partial messages. This is entity-based as
     # the last part of the message (which is what is split into the
     # next message) probably won't have a filename.
@@ -100,6 +107,19 @@
                                 'fragmented message section in %s', $id);
     }
 
+    # Search for message/external-body messages. This is entity-based
+    # as, almost by definition, we won't have the filename worked out
+    # for the file that is external.
+    if ((! MailScanner::Config::Value('allowexternal', $message)) &&
+        FindExternalBody($message, $ent)) {
+      $counter++;
+      MailScanner::Log::WarnLog('Content Checks: Detected and rejected ' .
+                                'external message body in %s', $id);
+    }
+
+    # Do the remaining checks if any recipient wants dangerous content checking
+    next unless MailScanner::Config::Value('dangerscan', $message) =~ /1/;
+
     # Go through the attachments and remove any that are bigger than this
     # user/domain/site is allowed.
     my $maxmessagesize = MailScanner::Config::Value('maxmessagesize', $message);
@@ -165,16 +185,6 @@
                                 'specific exploits in %s', $id);
     }
 
-    # Search for message/external-body messages. This is entity-based
-    # as, almost by definition, we won't have the filename worked out
-    # for the file that is external.
-    if ((! MailScanner::Config::Value('allowexternal', $message)) &&
-        FindExternalBody($message, $ent)) {
-      $counter++;
-      MailScanner::Log::WarnLog('Content Checks: Detected and rejected ' .
-                                'external message body in %s', $id);
-    }
-
     # Look for encrypted messages. They can allow some and block some
     # so we need to find the messages then apply the rules to the result.
     my $reason;