Change screenshot location

This commit is contained in:
Illya Marchenko 2024-11-11 21:18:29 +02:00
parent 8df9a270ae
commit e3f841af59
Signed by: stuzer05
GPG Key ID: A6ABAAA9268F9F4F

View File

@ -44,13 +44,13 @@ class easy_unsubscribe extends rcube_plugin {
// Array to store all patterns we want to match
$patterns = [
// Standard <a> tag pattern
'/<a\s+(?:[^>]*?\s+)?href=(["\'])((?:https?:)?\/\/[^"\']*?(?:unsubscribe|dummy-esclick)[^"\']*)\1/i',
'/<a\s+(?:[^>]*?\s+)?href=(["\'])((?:https?:)?\/\/[^"\']*?(?:unsubscribe)[^"\']*)\1/i',
// Square bracket pattern [URL] common in email templates
'/\[\s*((?:https?:)?\/\/[^\]]*?(?:unsubscribe|dummy-esclick)[^\]]*)\s*\]/i',
'/\[\s*((?:https?:)?\/\/[^\]]*?(?:unsubscribe)[^\]]*)\s*\]/i',
// Bare URLs with unsubscribe/esclick
'/((?:https?:)?\/\/[^\s<>\[\]"\']*?(?:unsubscribe|dummy-esclick)[^\s<>\[\]"\']*)/i'
'/((?:https?:)?\/\/[^\s<>\[\]"\']*?(?:unsubscribe)[^\s<>\[\]"\']*)/i'
];
$allUrls = [];
@ -80,7 +80,6 @@ class easy_unsubscribe extends rcube_plugin {
if($this->message_headers_done === false) {
$this->message_headers_done = true;
if(!isset($p['headers']->others['list-unsubscribe'])) return $p;
$urls = [];
@ -89,7 +88,7 @@ class easy_unsubscribe extends rcube_plugin {
$urls = array_merge($urls, $this->extractUnsubscribeUrls($body));
$ListUnsubscribe = $this->decodeMimeHeader($p['headers']->others['list-unsubscribe']);
$ListUnsubscribe = $this->decodeMimeHeader($p['headers']->others['list-unsubscribe'] ?? '');
if (preg_match_all('/<(.+)>/mU', $ListUnsubscribe, $items, PREG_PATTERN_ORDER)) {
foreach ( $items[1] as $uri ) {
$urls[] = $uri;
@ -98,9 +97,20 @@ class easy_unsubscribe extends rcube_plugin {
$urls = array_unique($urls);
$exclude_strings = ['?', 'esputnik', 'unsubscribe/'];
foreach ($urls as $uri) {
if (str_contains($uri, 'mailto')) continue;
if (!str_contains($uri, '?') && !str_contains($uri, 'esputnik')) continue;
$should_continue = false;
foreach ($exclude_strings as $exclude_string) {
if (str_contains($uri, $exclude_string)) {
$should_continue = true;
break;
}
}
if (!$should_continue) continue;
$this->unsubscribe_img .= '<a class="easy_unsubscribe_link" title="'.$uri.'" data-href="'. htmlentities($uri) .'" target="_blank" onclick="easy_unsubscribe_click(this);"><img src="plugins/easy_unsubscribe/icon.png" alt="' . $this->gettext('unsubscribe') . '" /></a>';
}