]> source.dussan.org Git - rspamd.git/commitdiff
[Feature] Match the beginning of pattern as well
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Wed, 13 Apr 2016 13:50:38 +0000 (14:50 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Wed, 13 Apr 2016 13:50:38 +0000 (14:50 +0100)
src/libutil/multipattern.c
src/libutil/multipattern.h

index 229ef2a9b4bb2833327b241d908c8b1b6baabf02..15c0d641b67bf3123ed1541e68638d5869153758 100644 (file)
@@ -392,7 +392,7 @@ rspamd_multipattern_add_pattern (struct rspamd_multipattern *mp,
 
 #ifdef WITH_HYPERSCAN
        gchar *np;
-       gint fl = 0;
+       gint fl = HS_FLAG_SOM_LEFTMOST;
 
        if (mp->flags & RSPAMD_MULTIPATTERN_ICASE) {
                fl |= HS_FLAG_CASELESS;
@@ -501,7 +501,7 @@ rspamd_multipattern_hs_cb (unsigned int id,
        struct rspamd_multipattern_cbdata *cbd = ud;
        gint ret;
 
-       ret = cbd->cb (cbd->mp, id, to, cbd->in, cbd->len, cbd->ud);
+       ret = cbd->cb (cbd->mp, id, from, to, cbd->in, cbd->len, cbd->ud);
 
        cbd->nfound ++;
        cbd->ret = ret;
@@ -514,8 +514,11 @@ rspamd_multipattern_acism_cb (int strnum, int textpos, void *context)
 {
        struct rspamd_multipattern_cbdata *cbd = context;
        gint ret;
+       ac_trie_pat_t pat;
 
-       ret = cbd->cb (cbd->mp, strnum, textpos, cbd->in, cbd->len, cbd->ud);
+       pat = g_array_index (cbd->mp->pats, ac_trie_pat_t, strnum);
+       ret = cbd->cb (cbd->mp, strnum, textpos - pat.len,
+                       textpos, cbd->in, cbd->len, cbd->ud);
 
        cbd->nfound ++;
        cbd->ret = ret;
index c2797715900489537d1e4fe71380b707113436bb..345bfe33f0f7c8e34435ada9bdfc60a9ce955c80 100644 (file)
@@ -50,7 +50,8 @@ struct rspamd_multipattern;
  */
 typedef gint (*rspamd_multipattern_cb_t) (struct rspamd_multipattern *mp,
                guint strnum,
-               gint textpos,
+               gint match_start,
+               gint match_pos,
                const gchar *text,
                gsize len,
                void *context);