aboutsummaryrefslogtreecommitdiffstats
path: root/src/lua
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2015-12-09 17:46:26 +0000
committerVsevolod Stakhov <vsevolod@highsecure.ru>2015-12-09 17:46:26 +0000
commit6d3508fb34675bd329fc9fdd3bb17c7647ad47d2 (patch)
treefe44724ecc113dcf7197882a44f02ba4efdafe3e /src/lua
parenta81c98004e33a7cf2cd987cff82c3fa237bfb280 (diff)
downloadrspamd-6d3508fb34675bd329fc9fdd3bb17c7647ad47d2.tar.gz
rspamd-6d3508fb34675bd329fc9fdd3bb17c7647ad47d2.zip
Fix pcre post-filtering
Diffstat (limited to 'src/lua')
-rw-r--r--src/lua/lua_regexp.c25
1 files changed, 24 insertions, 1 deletions
diff --git a/src/lua/lua_regexp.c b/src/lua/lua_regexp.c
index d19ed83e6..385e974cc 100644
--- a/src/lua/lua_regexp.c
+++ b/src/lua/lua_regexp.c
@@ -43,6 +43,7 @@ LUA_FUNCTION_DEF (regexp, get_cached);
LUA_FUNCTION_DEF (regexp, get_pattern);
LUA_FUNCTION_DEF (regexp, set_limit);
LUA_FUNCTION_DEF (regexp, set_max_hits);
+LUA_FUNCTION_DEF (regexp, get_max_hits);
LUA_FUNCTION_DEF (regexp, search);
LUA_FUNCTION_DEF (regexp, match);
LUA_FUNCTION_DEF (regexp, matchn);
@@ -54,6 +55,7 @@ static const struct luaL_reg regexplib_m[] = {
LUA_INTERFACE_DEF (regexp, get_pattern),
LUA_INTERFACE_DEF (regexp, set_limit),
LUA_INTERFACE_DEF (regexp, set_max_hits),
+ LUA_INTERFACE_DEF (regexp, get_max_hits),
LUA_INTERFACE_DEF (regexp, match),
LUA_INTERFACE_DEF (regexp, matchn),
LUA_INTERFACE_DEF (regexp, search),
@@ -271,7 +273,8 @@ lua_regexp_set_limit (lua_State *L)
/***
* @method re:set_max_hits(lim)
* Set maximum number of hits returned by a regexp
- * @param {number} lim limit in bytes
+ * @param {number} lim limit in hits count
+ * @return {number} old number of max hits
*/
static int
lua_regexp_set_max_hits (lua_State *L)
@@ -292,6 +295,26 @@ lua_regexp_set_max_hits (lua_State *L)
}
/***
+ * @method re:get_max_hits(lim)
+ * Get maximum number of hits returned by a regexp
+ * @return {number} number of max hits
+ */
+static int
+lua_regexp_get_max_hits (lua_State *L)
+{
+ struct rspamd_lua_regexp *re = lua_check_regexp (L);
+
+ if (re && re->re && !IS_DESTROYED (re)) {
+ lua_pushnumber (L, rspamd_regexp_get_maxhits (re->re));
+ }
+ else {
+ lua_pushnumber (L, 1);
+ }
+
+ return 1;
+}
+
+/***
* @method re:search(line[, raw[, capture]])
* Search line in regular expression object. If line matches then this
* function returns the table of captured strings. Otherwise, nil is returned.