commit 4184776: [Fix] Fix tld compositon rules
Vsevolod Stakhov
vsevolod at highsecure.ru
Tue Feb 25 17:07:06 UTC 2020
Author: Vsevolod Stakhov
Date: 2020-02-25 17:01:00 +0000
URL: https://github.com/rspamd/rspamd/commit/4184776a1744bfa1e73eac80e8126573d8aae0f0 (HEAD -> master)
[Fix] Fix tld compositon rules
Issue: #3248, #3268
---
src/libserver/url.c | 7 +++----
src/libutil/multipattern.c | 10 +++++-----
2 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/src/libserver/url.c b/src/libserver/url.c
index dcf13cfda..0407490d8 100644
--- a/src/libserver/url.c
+++ b/src/libserver/url.c
@@ -442,7 +442,6 @@ rspamd_url_parse_tld_file (const gchar *fname,
flags = URL_FLAG_NOHTML | URL_FLAG_TLD_MATCH;
-#ifndef WITH_HYPERSCAN
if (linebuf[0] == '*') {
flags |= URL_FLAG_STAR_MATCH;
p = strchr (linebuf, '.');
@@ -456,9 +455,6 @@ rspamd_url_parse_tld_file (const gchar *fname,
else {
p = linebuf;
}
-#else
- p = linebuf;
-#endif
m.flags = flags;
rspamd_multipattern_add_pattern (url_scanner->search_trie, p,
@@ -1553,6 +1549,9 @@ rspamd_tld_trie_callback (struct rspamd_multipattern *mp,
ndots--;
pos = p + 1;
}
+ else {
+ pos = p;
+ }
p--;
}
diff --git a/src/libutil/multipattern.c b/src/libutil/multipattern.c
index 6eec009b3..f243c1d8a 100644
--- a/src/libutil/multipattern.c
+++ b/src/libutil/multipattern.c
@@ -108,7 +108,6 @@ rspamd_multipattern_escape_tld_hyperscan (const gchar *pattern, gsize slen,
*/
if (pattern[0] == '*') {
- len = slen + 4;
p = strchr (pattern, '.');
if (p == NULL) {
@@ -119,12 +118,13 @@ rspamd_multipattern_escape_tld_hyperscan (const gchar *pattern, gsize slen,
p ++;
}
- prefix = ".*.";
+ prefix = "\\.";
+ len = slen + strlen (prefix);
}
else {
- len = slen + 1;
- prefix = ".";
+ prefix = "\\.";
p = pattern;
+ len = slen + strlen (prefix);
}
res = g_malloc (len + 1);
@@ -208,7 +208,7 @@ rspamd_multipattern_pattern_filter (const gchar *pattern, gsize len,
tmp = rspamd_multipattern_escape_tld_hyperscan (pattern, len, &tlen);
ret = rspamd_str_regexp_escape (tmp, tlen, dst_len,
- gl_flags|RSPAMD_REGEXP_ESCAPE_GLOB);
+ gl_flags|RSPAMD_REGEXP_ESCAPE_RE);
g_free (tmp);
}
else if (flags & RSPAMD_MULTIPATTERN_RE) {
More information about the Commits
mailing list