From ee951d3aae14fcd054f9771f48dd5f518f351a0c Mon Sep 17 00:00:00 2001 From: jangliss Date: Sat, 10 Mar 2007 04:10:46 +0000 Subject: [PATCH] Some fixes for #1634735. - Issue in filters using 'yes' instead of SMPREF_ON - Using fact that get host function returns hostname if unresolved git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@12331 7612ce4b-ef26-0410-bec9-ea0150e637f0 --- ChangeLog | 1 + plugins/filters/filters.php | 22 +++++++++++++++------- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/ChangeLog b/ChangeLog index fb4ce220..acf83c48 100644 --- a/ChangeLog +++ b/ChangeLog @@ -187,6 +187,7 @@ Version 1.5.2 - SVN - Fix Priority and Receipt compose options being reset after return from HTML addressbook, and allow returning from an empty address book (#1673056). - Do not special case the 'None' folder. + - Fixes for filters issues (#1634735). Version 1.5.1 (branched on 2006-02-12) -------------------------------------- diff --git a/plugins/filters/filters.php b/plugins/filters/filters.php index 10b703d2..aefbf659 100644 --- a/plugins/filters/filters.php +++ b/plugins/filters/filters.php @@ -25,7 +25,7 @@ global $UseSeparateImapConnection, $SpamFilters_CacheTTL; /** - * load required functions. Plugin depends on IMAP functions and they are not + * load required functions. Plugin depends on IMAP functions and they are not * loaded in src/webmail.php */ include_once (SM_PATH . 'functions/imap.php'); @@ -211,7 +211,7 @@ function start_filters($hook_args) { $AllowSpamFilters = false; foreach($spamfilters as $filterskey=>$value) { - if ($value['enabled'] == 'yes') { + if ($value['enabled'] == SMPREF_ON) { $AllowSpamFilters = true; break; } @@ -547,8 +547,12 @@ function filters_spam_check_site($a, $b, $c, $d, &$filters) { foreach ($filters as $key => $value) { if ($filters[$key]['enabled']) { if ($filters[$key]['dns']) { + /** + * RFC allows . on end of hostname to force domain lookup + * to not use search domain from resolv.conf + */ $filter_revip = $d . '.' . $c . '.' . $b . '.' . $a . '.' . - $filters[$key]['dns']; + $filters[$key]['dns'] . '.'; if(!isset($SpamFilters_DNScache[$filter_revip]['L'])) $SpamFilters_DNScache[$filter_revip]['L'] = ''; @@ -562,8 +566,12 @@ function filters_spam_check_site($a, $b, $c, $d, &$filters) { $SpamFilters_DNScache[$filter_revip]['T'] = time() + $SpamFilters_CacheTTL; } - if ($SpamFilters_DNScache[$filter_revip]['L'] == - $filters[$key]['result']) { + + /** + * gethostbyname returns ip if resolved, or returns original + * host query if no resolution + */ + if ($SpamFilters_DNScache[$filter_revip]['L'] != $filter_revip) { return 1; } } @@ -716,7 +724,7 @@ function load_spam_filters() { $filters['SPAMhaus']['name'] = 'SPAMhaus Lists'; $filters['SPAMhaus']['link'] = 'http://www.spamhaus.org'; $filters['SPAMhaus']['dns'] = 'sbl.spamhaus.org'; - $filters['SPAMhaus']['result'] = '127.0.0.6'; + $filters['SPAMhaus']['result'] = '127.0.0.2'; $filters['SPAMhaus']['comment'] = _("FREE - SPAMhaus - A list of well-known SPAM sources."); @@ -857,7 +865,7 @@ function load_spam_filters() { _("FREE - Distributed Sender Boycott List - UN-Confirmed Relays"); foreach ($filters as $Key => $Value) { - $filters[$Key]['enabled'] = getPref($data_dir, $username, $filters[$Key]['prefname']); + $filters[$Key]['enabled'] = (bool)getPref($data_dir, $username, $filters[$Key]['prefname']); } return $filters; -- 2.25.1