diff --git a/mailscanner/do_message_ops.php b/mailscanner/do_message_ops.php index de14d58b..e7eef5e9 100644 --- a/mailscanner/do_message_ops.php +++ b/mailscanner/do_message_ops.php @@ -96,7 +96,10 @@ echo '' . $items . '' . "\n"; } else { if (count($items) > 0) { - $num = 0; + // Originally this was 0, which assumed entire message was first item + // Now pass -1, which will inform quarantine_release and quarantine_learn + // to scan for entire message regardless of its position in the items list + $num = -1; $itemnum = [$num]; echo ''; if ('release' === $type) { diff --git a/mailscanner/functions.php b/mailscanner/functions.php index 5f14fd7b..7f333af4 100644 --- a/mailscanner/functions.php +++ b/mailscanner/functions.php @@ -3528,7 +3528,12 @@ function quarantine_list_items($msgid, $rpc_only = false) $quarantined[$count]['to'] = $row->to_address; $quarantined[$count]['file'] = $f; $file = escapeshellarg($quarantine . '/' . $f); - $quarantined[$count]['type'] = ltrim(rtrim(shell_exec('/usr/bin/file -bi ' . $file))); + $type = ltrim(rtrim(shell_exec('/usr/bin/file -bi ' . $file))); + // In some cases file returns text/x-mail instead of message/rfc822 + if (preg_match('!^text/x-mail!', $type)) { + $type = 'message/rfc822'; + } + $quarantined[$count]['type'] = $type; $quarantined[$count]['path'] = $quarantine . '/' . $f; $quarantined[$count]['md5'] = md5($quarantine . '/' . $f); $quarantined[$count]['dangerous'] = $infected; @@ -3576,6 +3581,18 @@ function quarantine_release($list, $num, $to, $rpc_only = false) $new = quarantine_list_items($list[0]['msgid']); $list = &$new; + // Check for [-1], indicating just to release message itself, regardless of its item position + if ($num[0] === -1) { + $num = [0]; + // Locate message in items + for ($index=0;$index