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);
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,
"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"
"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,
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']
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