/* Check regexp stuff */
if (re_map->map_flags & RSPAMD_REGEXP_MAP_FLAG_GLOB) {
+ char *anchored;
+
escaped = rspamd_str_regexp_escape(key, strlen(key), &escaped_len,
RSPAMD_REGEXP_ESCAPE_GLOB | RSPAMD_REGEXP_ESCAPE_UTF);
- re = rspamd_regexp_new(escaped, NULL, &err);
+ /* Glob semantics: the pattern must match the subject as a whole */
+ anchored = g_strdup_printf("^(?:%s)$", escaped);
+ re = rspamd_regexp_new(anchored, NULL, &err);
+ g_free(anchored);
g_free(escaped);
}
else {
... Settings={symbols_enabled = [REGEXP_MAP]}
Do Not Expect Symbol REGEXP_MAP
+MAP - FROM GLOB EXACT HIT
+ Scan File ${MESSAGE} From=user@t.co
+ ... Settings={symbols_enabled = [GLOB_MAP]}
+ Expect Symbol GLOB_MAP
+
+MAP - FROM GLOB SUBSTRING MISS
+ Scan File ${MESSAGE} From=user@walmart.com
+ ... Settings={symbols_enabled = [GLOB_MAP]}
+ Do Not Expect Symbol GLOB_MAP
+
+MAP - FROM GLOB WILDCARD HIT
+ Scan File ${MESSAGE} From=user@foo.bit.ly
+ ... Settings={symbols_enabled = [GLOB_MAP]}
+ Expect Symbol GLOB_MAP
+
+MAP - FROM GLOB WILDCARD SUPERSTRING MISS
+ Scan File ${MESSAGE} From=user@foo.bit.ly.evil.com
+ ... Settings={symbols_enabled = [GLOB_MAP]}
+ Do Not Expect Symbol GLOB_MAP
+
MAP - RCPT DOMAIN HIT
Scan File ${MESSAGE} Rcpt=user@example.com
... Settings={symbols_enabled = [RCPT_DOMAIN]}
map = "{= env.TESTDIR =}/configs/maps/regexp.list";
require_symbols = "(R_SPF_ALLOW|R_SPF_DNSFAIL) & REGEXP_MAP & !FROM_MAP";
}
+ GLOB_MAP {
+ type = "from";
+ filter = "email:domain";
+ glob = true;
+ map = "{= env.TESTDIR =}/configs/maps/glob.list";
+ }
RCPT_DOMAIN {
type = "rcpt";
filter = "email:domain";