diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2015-06-30 18:26:48 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2015-06-30 18:26:48 +0100 |
commit | 0e85c23ee12fa524ac9056ee0275fd3c4b15c612 (patch) | |
tree | ba0fcbe01a55297f9264762022bbfa68daa20559 /src | |
parent | f826e627cf53496b3ec79be2cc72a5445c89db19 (diff) | |
download | rspamd-0e85c23ee12fa524ac9056ee0275fd3c4b15c612.tar.gz rspamd-0e85c23ee12fa524ac9056ee0275fd3c4b15c612.zip |
Fix issues with capturing patterns
Diffstat (limited to 'src')
-rw-r--r-- | src/libutil/regexp.c | 6 | ||||
-rw-r--r-- | src/lua/lua_regexp.c | 4 |
2 files changed, 4 insertions, 6 deletions
diff --git a/src/libutil/regexp.c b/src/libutil/regexp.c index 529895b7b..da9884ec1 100644 --- a/src/libutil/regexp.c +++ b/src/libutil/regexp.c @@ -335,7 +335,7 @@ fin: rspamd_regexp_generate_id (pattern, flags, res->id); /* Check number of captures */ - if (pcre_fullinfo (res->re, res->extra, PCRE_INFO_CAPTURECOUNT, + if (pcre_fullinfo (res->raw_re, res->extra, PCRE_INFO_CAPTURECOUNT, &ncaptures) == 0) { res->ncaptures = ncaptures; } @@ -445,9 +445,9 @@ rspamd_regexp_search (rspamd_regexp_t *re, const gchar *text, gsize len, g_assert (g_array_get_element_size (captures) == sizeof (struct rspamd_re_capture)); - g_array_set_size (captures, rc - 1); + g_array_set_size (captures, rc); - for (i = 0; i < rc - 1; i ++) { + for (i = 0; i < rc; i ++) { elt = &g_array_index (captures, struct rspamd_re_capture, i); elt->p = mt + ovec[i * 2]; elt->len = (mt + ovec[i * 2 + 1]) - elt->p; diff --git a/src/lua/lua_regexp.c b/src/lua/lua_regexp.c index 60dbc5edc..2f7ea3ea1 100644 --- a/src/lua/lua_regexp.c +++ b/src/lua/lua_regexp.c @@ -348,14 +348,12 @@ lua_regexp_search (lua_State *L) if (capture) { lua_newtable (L); - lua_pushlstring (L, start, end - start); - lua_rawseti (L, -2, 1); for (capn = 0; capn < captures->len; capn ++) { cap = &g_array_index (captures, struct rspamd_re_capture, capn); lua_pushlstring (L, cap->p, cap->len); - lua_rawseti (L, -2, capn + 2); + lua_rawseti (L, -2, capn + 1); } lua_rawseti (L, -2, ++i); |