[evolution-data-server] Mis-filters emails with Mailing List rule in certain situations



commit b361524922dd2945dd848b96cde4ab968a13c881
Author: Milan Crha <mcrha redhat com>
Date:   Fri May 19 09:37:09 2017 +0200

    Mis-filters emails with Mailing List rule in certain situations
    
    When the filter rule value starts with an '@', but the List-Id header
    has no '@' part, then the filter changes the value to pre-domain part,
    which is an empty string here, and compares it to the List-Id value,
    which basically always succeeds. The change here makes sure that there
    are never compared empty strings.
    
    Other part of this change enhances filters logging.
    
    This had been reported downstream:
    https://bugzilla.redhat.com/show_bug.cgi?id=1450560

 src/camel/camel-filter-driver.c  |   10 +++++-----
 src/camel/camel-filter-search.c  |   13 +++++++++----
 src/camel/camel-search-private.c |    2 +-
 3 files changed, 15 insertions(+), 10 deletions(-)
---
diff --git a/src/camel/camel-filter-driver.c b/src/camel/camel-filter-driver.c
index 44408d8..abcd79e 100644
--- a/src/camel/camel-filter-driver.c
+++ b/src/camel/camel-filter-driver.c
@@ -1304,13 +1304,13 @@ camel_filter_driver_log (CamelFilterDriver *driver,
                        subject = camel_message_info_get_subject (driver->priv->info);
 
                        time (&t);
-                       strftime (date, 49, "%a, %d %b %Y %H:%M:%S", localtime (&t));
+                       strftime (date, 49, "%Y-%m-%d %H:%M:%S", localtime (&t));
                        fprintf (
                                driver->priv->logfile,
-                               "Applied filter \"%s\" to "
-                               "message from %s - \"%s\" at %s\n",
-                               str, from ? from : "unknown",
-                               subject ? subject : "", date);
+                               "%s - Applied filter \"%s\" to "
+                               "message from %s - \"%s\"\n",
+                               date, str, from ? from : "unknown",
+                               subject ? subject : "");
 
                        break;
                }
diff --git a/src/camel/camel-filter-search.c b/src/camel/camel-filter-search.c
index a3eb6d6..21374f4 100644
--- a/src/camel/camel-filter-search.c
+++ b/src/camel/camel-filter-search.c
@@ -155,16 +155,21 @@ static CamelMimeMessage *
 camel_filter_search_get_message (FilterMessageSearch *fms,
                                  struct _CamelSExp *sexp)
 {
+       GError *local_error = NULL;
+
        if (fms->message)
                return fms->message;
 
-       fms->message = fms->get_message (fms->get_message_data, fms->cancellable, fms->error);
+       fms->message = fms->get_message (fms->get_message_data, fms->cancellable, &local_error);
 
        if (fms->message == NULL) {
-               camel_filter_search_log (fms, "Failed to retrieve message");
+               camel_filter_search_log (fms, "Failed to retrieve message: %s", local_error ? 
local_error->message : "Unknown error");
                camel_sexp_fatal_error (sexp, _("Failed to retrieve message"));
        }
 
+       if (local_error)
+               g_propagate_error (fms->error, local_error);
+
        return fms->message;
 }
 
@@ -284,11 +289,11 @@ check_header (struct _CamelSExp *f,
                if (g_ascii_strcasecmp (name, "x-camel-mlist") == 0) {
                        const gchar *list = camel_message_info_get_mlist (fms->info);
 
-                       if (list) {
+                       if (list && *list) {
                                for (i = 1; i < argc && !matched; i++) {
                                        if (argv[i]->type == CAMEL_SEXP_RES_STRING) {
                                                matched = camel_search_header_match (list, 
argv[i]->value.string, how, CAMEL_SEARCH_TYPE_MLIST, NULL);
-                                               camel_filter_search_log (fms, "Mailing list header does 
%smatch '%s'", matched ? "" : "not ", argv[i]->value.string);
+                                               camel_filter_search_log (fms, "Mailing list header value '%s' 
does %smatch '%s'", list, matched ? "" : "not ", argv[i]->value.string);
                                        }
                                }
                        }
diff --git a/src/camel/camel-search-private.c b/src/camel/camel-search-private.c
index 8b39ea2..29cbabe 100644
--- a/src/camel/camel-search-private.c
+++ b/src/camel/camel-search-private.c
@@ -469,7 +469,7 @@ camel_search_header_match (const gchar *value,
                 * which should be common. */
                vdom = strchr (value, '@');
                mdom = strchr (match, '@');
-               if (mdom != NULL && vdom == NULL) {
+               if (mdom != NULL && mdom != match && vdom == NULL) {
                        v = g_alloca (mdom - match + 1);
                        memcpy (v, match, mdom - match);
                        v[mdom - match] = 0;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]