Skip to content

Commit cf7c67f

Browse files
committed
🔒 Add from_address emptiness check to prevent mailbox sync failures on null addresses
- Skip blocked email and matching rule checks when message from_address is empty to avoid errors - Wrap existing block rule logic in from_address presence checks for both new message import and matching rule evaluation - Prevents edge-case crashes when processing emails without a valid sender address
1 parent 56dcfe0 commit cf7c67f

1 file changed

Lines changed: 9 additions & 5 deletions

File tree

‎lhc_web/lib/core/lhmailconv/lhmailconvparser.php‎

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -630,9 +630,11 @@ public static function syncMailbox($mailbox, $params = []) {
630630
}
631631

632632
// Check is mail blocked only if matched rule is not a blocked one rule is not a blocking one
633-
if ((!(isset($matchingRuleSelected->options_array['block_rule']) && $matchingRuleSelected->options_array['block_rule'] == true)) && erLhcoreClassModelChatBlockedUser::isBlocked(array('email_conv' => $message->from_address))) {
634-
$statsImport[] = 'Skipping e-mail because of block for e-mail - ' . $message->from_address . ' - ' . $vars['message_id'] . ' - ' . $mailInfo->uid;
635-
continue;
633+
if (!empty($message->from_address)) {
634+
if ((!(isset($matchingRuleSelected->options_array['block_rule']) && $matchingRuleSelected->options_array['block_rule'] == true)) && erLhcoreClassModelChatBlockedUser::isBlocked(array('email_conv' => $message->from_address))) {
635+
$statsImport[] = 'Skipping e-mail because of block for e-mail - ' . $message->from_address . ' - ' . $vars['message_id'] . ' - ' . $mailInfo->uid;
636+
continue;
637+
}
636638
}
637639

638640
$rfc822RawBody = '';
@@ -1446,8 +1448,10 @@ public static function getMatchingRuleByMessage($message, $filteredMatchingRules
14461448
}
14471449

14481450
// If it is block rule but e-mail is not blocked. Skip the rule.
1449-
if (isset($matchingRule->options_array['block_rule']) && $matchingRule->options_array['block_rule'] == true && !erLhcoreClassModelChatBlockedUser::isBlocked(array('email_conv' => $message->from_address))) {
1450-
$matched = false;
1451+
if (!empty($message->from_address)) {
1452+
if (isset($matchingRule->options_array['block_rule']) && $matchingRule->options_array['block_rule'] == true && !erLhcoreClassModelChatBlockedUser::isBlocked(array('email_conv' => $message->from_address))) {
1453+
$matched = false;
1454+
}
14511455
}
14521456

14531457
if (!empty($matchingRule->from_name)) {

0 commit comments

Comments
 (0)