Skip to content

Commit

Permalink
[mms] Fix blacklist/whitelist matching with IMAP backend (Bug #13031).
Browse files Browse the repository at this point in the history
  • Loading branch information
slusarz committed Mar 23, 2014
1 parent 4ab34a3 commit 8a4263e
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 5 deletions.
1 change: 1 addition & 0 deletions ingo/docs/CHANGES
Expand Up @@ -2,6 +2,7 @@
v3.1.5-git
----------

[mms] Fix blacklist/whitelist matching with IMAP backend (Bug #13031).
[mms] Fix procmail reject recipe (Bug #13060; admin@dei.unipd.it).


Expand Down
20 changes: 15 additions & 5 deletions ingo/lib/Script/Imap.php
Expand Up @@ -138,28 +138,38 @@ public function perform($change)
continue;
}

$addr = new Horde_Mail_Rfc822_List($addr);

$query = $this->_getQuery();
$or_ob = new Horde_Imap_Client_Search_Query();
foreach ($addr as $val) {
foreach ($addr->bare_addresses as $val) {
$ob = new Horde_Imap_Client_Search_Query();
$ob->headerText('from', $val);
$or_ob->orSearch(array($ob));
}
$query->andSearch(array($or_ob));
$indices = $api->search($query);

/* Remove any indices that got in there by way of partial
* address match. */
if (!$msgs = $api->fetchEnvelope($indices)) {
continue;
}

/* Remove any indices that got in there by way of partial
* address match. */
$remove = array();
foreach ($msgs as $v) {
if (!$v->getEnvelope()->from->match($addr)) {
$indices = array_diff($indices, array($v->getUid()));
foreach ($v->getEnvelope()->from as $v2) {
if (!$addr->contains($v2)) {
$remove[] = $v->getUid();
break;
}
}
}

if ($remove) {
$indices = array_diff($indices, $remove);
}

if ($rule['action'] == Ingo_Storage::ACTION_BLACKLIST) {
$indices = array_diff($indices, $ignore_ids);
if (!empty($indices)) {
Expand Down
2 changes: 2 additions & 0 deletions ingo/package.xml
Expand Up @@ -33,6 +33,7 @@
</stability>
<license uri="http://www.horde.org/licenses/apache">ASL</license>
<notes>
* [mms] Fix blacklist/whitelist matching with IMAP backend (Bug #13031).
* [mms] Fix procmail reject recipe (Bug #13060; admin@dei.unipd.it).
</notes>
<contents>
Expand Down Expand Up @@ -1344,6 +1345,7 @@
<date>2014-03-10</date>
<license uri="http://www.horde.org/licenses/apache">ASL</license>
<notes>
* [mms] Fix blacklist/whitelist matching with IMAP backend (Bug #13031).
* [mms] Fix procmail reject recipe (Bug #13060; admin@dei.unipd.it).
</notes>
</release>
Expand Down

0 comments on commit 8a4263e

Please sign in to comment.