]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
config: Escape wildcard characters in written event filters
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Tue, 2 May 2023 13:18:11 +0000 (16:18 +0300)
committerTimo Sirainen <timo.sirainen@open-xchange.com>
Mon, 20 Nov 2023 12:21:56 +0000 (14:21 +0200)
protocol and local_name are now compared as exact strings rather than
wildcards.

src/config/config-dump-full.c

index 3fb2802e5faa49317df42cec618bdb9f1786ebf5..0273813df244d2575fbcc91eaccfe614fe248b38 100644 (file)
@@ -3,6 +3,7 @@
 #include "lib.h"
 #include "str.h"
 #include "strescape.h"
+#include "wildcard-match.h"
 #include "safe-mkstemp.h"
 #include "ostream.h"
 #include "config-parser.h"
@@ -74,13 +75,18 @@ config_dump_full_append_filter(string_t *str,
        unsigned int prefix_len = str_len(str);
 
        if (filter->service != NULL) {
-               if (filter->service[0] != '!')
-                       str_printfa(str, "protocol=\"%s\" AND ", str_escape(filter->service));
-               else
-                       str_printfa(str, "NOT protocol=\"%s\" AND ", str_escape(filter->service + 1));
+               if (filter->service[0] != '!') {
+                       str_printfa(str, "protocol=\"%s\" AND ",
+                                   wildcard_str_escape(filter->service));
+               } else {
+                       str_printfa(str, "NOT protocol=\"%s\" AND ",
+                                   wildcard_str_escape(filter->service + 1));
+               }
+       }
+       if (filter->local_name != NULL) {
+               str_printfa(str, "local_name=\"%s\" AND ",
+                           wildcard_str_escape(filter->local_name));
        }
-       if (filter->local_name != NULL)
-               str_printfa(str, "local_name=\"%s\" AND ", str_escape(filter->local_name));
        if (filter->local_bits > 0) {
                str_printfa(str, "local_ip=\"%s/%u\" AND ",
                            net_ip2addr(&filter->local_net),