summaryrefslogtreecommitdiff
path: root/usr.sbin/smtpd/table.c
diff options
context:
space:
mode:
authorGilles Chehade <gilles@cvs.openbsd.org>2018-12-21 21:35:30 +0000
committerGilles Chehade <gilles@cvs.openbsd.org>2018-12-21 21:35:30 +0000
commit3e5a496dd5d27664c37c8038bf3ff08b81acda89 (patch)
tree6ed79f2857d7464935d7ed62ccbfc4efc7c81505 /usr.sbin/smtpd/table.c
parent4014ecb37423fedc8d1ee85d5bc2fd411838c67d (diff)
since we already support regex lookups in tables for builtin filters, let's
also support regex lookups in match rule criterias performing table lookups ok millert@
Diffstat (limited to 'usr.sbin/smtpd/table.c')
-rw-r--r--usr.sbin/smtpd/table.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/usr.sbin/smtpd/table.c b/usr.sbin/smtpd/table.c
index 7577193d152..187cb0edefb 100644
--- a/usr.sbin/smtpd/table.c
+++ b/usr.sbin/smtpd/table.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: table.c,v 1.32 2018/11/02 13:45:59 gilles Exp $ */
+/* $OpenBSD: table.c,v 1.33 2018/12/21 21:35:29 gilles Exp $ */
/*
* Copyright (c) 2013 Eric Faurot <eric@openbsd.org>
@@ -463,8 +463,14 @@ int
table_regex_match(const char *string, const char *pattern)
{
regex_t preg;
+ int cflags = REG_EXTENDED|REG_NOSUB;
- if (regcomp(&preg, pattern, REG_EXTENDED|REG_NOSUB) != 0)
+ if (strncmp(pattern, "(?i)", 4) == 0) {
+ cflags |= REG_ICASE;
+ pattern += 4;
+ }
+
+ if (regcomp(&preg, pattern, cflags) != 0)
return (0);
if (regexec(&preg, string, 0, NULL, 0) != 0)