Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added try/catch on sieve manager getScript #788

Merged
merged 1 commit into from
Oct 9, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
49 changes: 25 additions & 24 deletions modules/sievefilters/modules.php
Original file line number Diff line number Diff line change
Expand Up @@ -208,37 +208,38 @@ function get_blocked_senders($mailbox, $mailbox_id, $icon_svg, $icon_block_domai
try {
$client = $factory->init($user_config, $mailbox);
$scripts = $client->listScripts();
} catch (Exception $e) {
Hm_Msgs::add("ERRSieve: {$e->getMessage()}");
return '';
}
if (array_search('blocked_senders', $scripts, true) === false) {
return '';
}
$current_script = $client->getScript('blocked_senders');
if ($current_script != '') {
$base64_obj = str_replace("# ", "", preg_split('#\r?\n#', $current_script, 0)[1]);
$blocked_list = json_decode(base64_decode($base64_obj));
if (!$blocked_list) {

if (array_search('blocked_senders', $scripts, true) === false) {
return '';
}
foreach ($blocked_list as $blocked_sender) {
if (explode('@', $blocked_sender)[0] == '') {
$blocked_sender = '*'.$blocked_sender;
$current_script = $client->getScript('blocked_senders');
if ($current_script != '') {
$base64_obj = str_replace("# ", "", preg_split('#\r?\n#', $current_script, 0)[1]);
$blocked_list = json_decode(base64_decode($base64_obj));
if (!$blocked_list) {
return '';
}
foreach ($blocked_list as $blocked_sender) {
if (explode('@', $blocked_sender)[0] == '') {
$blocked_sender = '*'.$blocked_sender;
}
$blocked_senders[] = $blocked_sender;
}
$blocked_senders[] = $blocked_sender;
}
}

$ret = '';
foreach ($blocked_senders as $sender) {
$ret .= '<tr><td>'.$sender.'</td><td><img class="unblock_button" mailbox_id="'.$mailbox_id.'" src="'.$icon_svg.'" />';
if (!strstr($sender, '*')) {
$ret .= ' <img class="block_domain_button" mailbox_id="'.$mailbox_id.'" src="'.$icon_block_domain_svg.'" />';
$ret = '';
foreach ($blocked_senders as $sender) {
$ret .= '<tr><td>'.$sender.'</td><td><img class="unblock_button" mailbox_id="'.$mailbox_id.'" src="'.$icon_svg.'" />';
if (!strstr($sender, '*')) {
$ret .= ' <img class="block_domain_button" mailbox_id="'.$mailbox_id.'" src="'.$icon_block_domain_svg.'" />';
}
$ret .= '</tr></td></tr>';
}
$ret .= '</tr></td></tr>';
return $ret;
} catch (Exception $e) {
Hm_Msgs::add("ERRSieve: {$e->getMessage()}");
return '';
}
return $ret;
}


Expand Down