]> source.dussan.org Git - rspamd.git/commitdiff
[Feature] Support more hyperscan flags
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Tue, 24 Sep 2019 08:20:05 +0000 (09:20 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Tue, 24 Sep 2019 08:20:05 +0000 (09:20 +0100)
src/libutil/multipattern.c
src/libutil/multipattern.h
src/lua/lua_trie.c

index 7e812a0bd9c72b6ab22586bbac1faee9734d2deb..363cd800f97d041ba554444a6a330ecb3c435a69 100644 (file)
@@ -332,6 +332,16 @@ rspamd_multipattern_add_pattern_len (struct rspamd_multipattern *mp,
                if (mp->flags & RSPAMD_MULTIPATTERN_UTF8) {
                        fl |= HS_FLAG_UTF8|HS_FLAG_UCP;
                }
+               if (mp->flags & RSPAMD_MULTIPATTERN_DOTALL) {
+                       fl |= HS_FLAG_DOTALL;
+               }
+               if (mp->flags & RSPAMD_MULTIPATTERN_SINGLEMATCH) {
+                       fl |= HS_FLAG_SINGLEMATCH;
+                       fl &= ~HS_FLAG_SOM_LEFTMOST; /* According to hyperscan docs */
+               }
+               if (mp->flags & RSPAMD_MULTIPATTERN_NO_START) {
+                       fl &= ~HS_FLAG_SOM_LEFTMOST;
+               }
 
                g_array_append_val (mp->hs_flags, fl);
                np = rspamd_multipattern_pattern_filter (pattern, patlen, flags, &dlen);
index 1eac4cf9aadd8eb4217792773cb534f72b82c1f9..03183bd4806b0736407471df1e59a0cc66c4984b 100644 (file)
@@ -38,6 +38,9 @@ enum rspamd_multipattern_flags {
        /* Not supported by acism */
        RSPAMD_MULTIPATTERN_GLOB = (1 << 3),
        RSPAMD_MULTIPATTERN_RE = (1 << 4),
+       RSPAMD_MULTIPATTERN_DOTALL = (1 << 5),
+       RSPAMD_MULTIPATTERN_SINGLEMATCH = (1 << 6),
+       RSPAMD_MULTIPATTERN_NO_START = (1 << 7),
 };
 
 struct rspamd_multipattern;
index 58a6698325621654b2805bc3f529db99a09054ab..a1b0de1189599d0282d20a006c07ed28d2a7c177 100644 (file)
@@ -430,6 +430,12 @@ lua_load_trie (lua_State *L)
        lua_setfield (L, -2, "utf8");
        lua_pushinteger (L, RSPAMD_MULTIPATTERN_TLD);
        lua_setfield (L, -2, "tld");
+       lua_pushinteger (L, RSPAMD_MULTIPATTERN_DOTALL);
+       lua_setfield (L, -2, "dot_all");
+       lua_pushinteger (L, RSPAMD_MULTIPATTERN_SINGLEMATCH);
+       lua_setfield (L, -2, "single_match");
+       lua_pushinteger (L, RSPAMD_MULTIPATTERN_NO_START);
+       lua_setfield (L, -2, "no_start");
        lua_settable (L, -3);
 
        /* Main content */