From fa9bd9c4f4b7120f566514d071a6aeae337dfbdc Mon Sep 17 00:00:00 2001 From: Steven Sullivan Date: Tue, 2 Oct 2018 08:40:26 -0400 Subject: [PATCH] To handle both URL and mailto: links in the unsubscribe list header --- easy_unsubscribe.php | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/easy_unsubscribe.php b/easy_unsubscribe.php index 644bb8c..b6a4a22 100644 --- a/easy_unsubscribe.php +++ b/easy_unsubscribe.php @@ -29,16 +29,16 @@ class easy_unsubscribe extends rcube_plugin $this->message_headers_done = true; $ListUnsubscribe = $p['headers']->others['list-unsubscribe']; - preg_match('/<(.*?)>/', $ListUnsubscribe, $rVal); + + preg_match('%\bhttps?://[^,\s()<>]+(?:\([\w\d]+\)|([^,[:punct:]\s]|/))%i', $ListUnsubscribe, $UnsubURL); + preg_match('/mailto:(.*?)>/', $ListUnsubscribe, $UnsubEmail); + + if(!empty($UnsubURL[0])) + $this->unsubscribe_img = 'Unsubscribe'; + + if(!empty($UnsubEmail[1])) + $this->unsubscribe_img .= 'Unsubscribe'; - if($rVal[1]!='') - $this->unsubscribe_img = 'Unsubscribe'; - else - { - preg_match('#\bhttps?://[^,\s()<>]+(?:\([\w\d]+\)|([^,[:punct:]\s]|/))#', $ListUnsubscribe, $rVal); - if($rVal[0]!='') - $this->unsubscribe_img = 'Unsubscribe'; - } } if(isset($p['output']['subject']))