diff options
author | Andrew Lewis <nerf@judo.za.org> | 2017-04-25 16:36:34 +0200 |
---|---|---|
committer | Andrew Lewis <nerf@judo.za.org> | 2017-04-25 16:36:34 +0200 |
commit | dd6c0e555e5bbef7ec3f969e27b0d16c4f92fe8a (patch) | |
tree | 1a7187dc6dd01bdb36adc654eb7dbf52d7389c14 | |
parent | 07f4054d92da116c8ac4ac8d7456706c319c5b38 (diff) | |
download | rspamd-dd6c0e555e5bbef7ec3f969e27b0d16c4f92fe8a.tar.gz rspamd-dd6c0e555e5bbef7ec3f969e27b0d16c4f92fe8a.zip |
[Fix] Rspamadm grep: Disable Lua patterns in string search by default
-rw-r--r-- | src/rspamadm/grep.c | 6 | ||||
-rw-r--r-- | src/rspamadm/grep.lua | 8 |
2 files changed, 12 insertions, 2 deletions
diff --git a/src/rspamadm/grep.c b/src/rspamadm/grep.c index b88347a8b..9665b40e8 100644 --- a/src/rspamadm/grep.c +++ b/src/rspamadm/grep.c @@ -25,6 +25,7 @@ static gchar **inputs = NULL; static gboolean sensitive = FALSE; static gboolean orphans = FALSE; static gboolean partial = FALSE; +static gboolean luapat = FALSE; static void rspamadm_grep (gint argc, gchar **argv); static const char *rspamadm_grep_help (gboolean full_help); @@ -39,6 +40,8 @@ struct rspamadm_command grep_command = { static GOptionEntry entries[] = { {"string", 's', 0, G_OPTION_ARG_STRING, &string, "Plain string to search (case-insensitive)", NULL}, + {"lua", 'l', 0, G_OPTION_ARG_NONE, &luapat, + "Use Lua patterns in string search", NULL}, {"pattern", 'p', 0, G_OPTION_ARG_STRING, &pattern, "Pattern to search for (regex)", NULL}, {"input", 'i', 0, G_OPTION_ARG_STRING_ARRAY, &inputs, @@ -63,6 +66,7 @@ rspamadm_grep_help (gboolean full_help) "Usage: rspamadm grep <-s string | -p pattern> [-i input1 -i input2 -S -o -P]\n" "Where options are:\n\n" "-s: Plain string to search (case-insensitive)\n" + "-l: Use Lua patterns in string search\n" "-p: Pattern to search for (regex)\n" "-i: Process specified inputs (stdin if unspecified)\n" "-S: Enable case-sensitivity in string search\n" @@ -137,6 +141,8 @@ rspamadm_grep (gint argc, gchar **argv) "orphans", 0, false); ucl_object_insert_key (obj, ucl_object_frombool (partial), "partial", 0, false); + ucl_object_insert_key (obj, ucl_object_frombool (luapat), + "luapat", 0, false); rspamadm_execute_lua_ucl_subr (L, argc, diff --git a/src/rspamadm/grep.lua b/src/rspamadm/grep.lua index 68dc2a92c..a9d4b084a 100644 --- a/src/rspamadm/grep.lua +++ b/src/rspamadm/grep.lua @@ -15,6 +15,10 @@ return function(_, res) end end + local plainm = true + if res['luapat'] then + plainm = false + end local orphans = res['orphans'] local search_str = res['string'] local sensitive = res['sensitive'] @@ -63,10 +67,10 @@ return function(_, res) if re then ismatch = re:match(line) elseif sensitive and search_str then - ismatch = string.find(line, search_str) + ismatch = string.find(line, search_str, 1, plainm) elseif search_str then local lwr = string.lower(line) - ismatch = string.find(lwr, search_str) + ismatch = string.find(lwr, search_str, 1, plainm) end if ismatch then if not hash then |