aboutsummaryrefslogtreecommitdiffstats
path: root/src/lua/lua_regexp.c
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2015-03-31 13:04:34 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2015-03-31 13:04:34 +0100
commite95c0ba5d42e1753faa9a35697f1074121c30775 (patch)
tree8b6e102ef195cbf697fb6f6a4006a3f7a7ea8b81 /src/lua/lua_regexp.c
parent6508194d6a66db21b59b8a32a35daeeb9dfaf049 (diff)
downloadrspamd-e95c0ba5d42e1753faa9a35697f1074121c30775.tar.gz
rspamd-e95c0ba5d42e1753faa9a35697f1074121c30775.zip
Allow raw matching of regexps from lua.
Diffstat (limited to 'src/lua/lua_regexp.c')
-rw-r--r--src/lua/lua_regexp.c11
1 files 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 {