From e95c0ba5d42e1753faa9a35697f1074121c30775 Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Tue, 31 Mar 2015 13:04:34 +0100 Subject: [PATCH] Allow raw matching of regexps from lua. --- src/lua/lua_regexp.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/lua/lua_regexp.c b/src/lua/lua_regexp.c index 58073b3bc..ba5281299 100644 --- a/src/lua/lua_regexp.c +++ b/src/lua/lua_regexp.c @@ -268,11 +268,12 @@ lua_regexp_search (lua_State *L) } /*** - * @method re:match(line) + * @method re:match(line[, raw_match]) * Matches line against the regular expression and return true if line matches * (partially or completely) * * @param {string} line match the specified line against regexp object + * @param {bool} match raw regexp instead of utf8 one * @return {table or nil} table of strings matched or nil * @example * local re = regexp.create_cached('/^\s*([0-9]+)\s*$/') @@ -286,11 +287,17 @@ lua_regexp_match (lua_State *L) struct rspamd_lua_regexp *re = lua_check_regexp (L); const gchar *data; gsize len; + gboolean raw = FALSE; if (re) { data = luaL_checklstring (L, 2, &len); + + if (lua_gettop (L) == 3) { + raw = lua_toboolean (L, 3); + } + if (data) { - if (rspamd_regexp_search (re->re, data, len, NULL, NULL, FALSE)) { + if (rspamd_regexp_search (re->re, data, len, NULL, NULL, raw)) { lua_pushboolean (L, TRUE); } else { -- 2.39.5