]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib: Warn about unsupported inequality string comparisons in event filters
authorKarl Fleischmann <karl.fleischmann@open-xchange.com>
Mon, 19 Dec 2022 14:18:40 +0000 (15:18 +0100)
committeraki.tuomi <aki.tuomi@open-xchange.com>
Mon, 9 Jan 2023 09:48:38 +0000 (09:48 +0000)
src/lib/event-filter-private.h
src/lib/event-filter.c

index 2c80b1d14dc59223261a4344722ad5a720268db6..bb9b0f638a95ad7eadb36f81a619137218120ea3 100644 (file)
@@ -87,6 +87,7 @@ struct event_filter_node {
 
        bool ambiguous_unit:1;
        bool warned_ambiguous_unit:1;
+       bool warned_string_inequality:1;
        bool warned_type_mismatch:1;
 };
 
index 335312f8295ebcab4f7a162006c27d8d1d3d2a61..3bb52d6d2b2d4a02e8fa0e02bed7660501c6b9eb 100644 (file)
@@ -254,6 +254,7 @@ clone_expr(pool_t pool, struct event_filter_node *old)
        new->ambiguous_unit = old->ambiguous_unit;
        new->warned_ambiguous_unit = old->warned_ambiguous_unit;
        new->warned_type_mismatch = old->warned_type_mismatch;
+       new->warned_string_inequality = old->warned_string_inequality;
 
        return new;
 }
@@ -590,8 +591,21 @@ event_match_field(struct event *event, struct event_filter_node *node,
 
        switch (field->value_type) {
        case EVENT_FIELD_VALUE_TYPE_STR:
+               /* We only support string equality comparisons. */
                if (node->op != EVENT_FILTER_OP_CMP_EQ) {
-                       /* we only support string equality comparisons */
+                       /* Warn about non-equality comparisons. */
+                       if (!node->warned_string_inequality) {
+                               const char *name = event->sending_name;
+                               /* Use i_warning to prevent event filter recursions. */
+                               i_warning("Event filter for string field '%s' "
+                                         "only supports equality operation "
+                                         "'=' not '%s'. (event=%s, source=%s:%u)",
+                                         wanted_field->key,
+                                         event_filter_export_query_expr_op(node->op),
+                                         name != NULL ? name : "",
+                                         source_filename, source_linenum);
+                               node->warned_string_inequality = TRUE;
+                       }
                        return FALSE;
                }
                if (field->value.str[0] == '\0') {