From 7522631b4a5d98a7a38429716f0e56286c7d3c2c Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Mon, 27 Mar 2017 10:01:56 +0100 Subject: [PATCH] [Fix] Fix templates grammar usage --- src/plugins/lua/dkim_signing.lua | 11 ++++------- src/plugins/lua/metadata_exporter.lua | 11 ++++------- 2 files changed, 8 insertions(+), 14 deletions(-) diff --git a/src/plugins/lua/dkim_signing.lua b/src/plugins/lua/dkim_signing.lua index c224c241a..e20089967 100644 --- a/src/plugins/lua/dkim_signing.lua +++ b/src/plugins/lua/dkim_signing.lua @@ -40,17 +40,14 @@ local E = {} local N = 'dkim_signing' local redis_params -local template_grammar local function simple_template(tmpl, keys) local lpeg = require "lpeg" - if not template_grammar then - local var_lit = lpeg.P { lpeg.R("az") + lpeg.R("AZ") + lpeg.R("09") + "_" } - local var = lpeg.P { (lpeg.P("$") / "") * ((var_lit^1) / keys) } - local var_braced = lpeg.P { (lpeg.P("${") / "") * ((var_lit^1) / keys) * (lpeg.P("}") / "") } + local var_lit = lpeg.P { lpeg.R("az") + lpeg.R("AZ") + lpeg.R("09") + "_" } + local var = lpeg.P { (lpeg.P("$") / "") * ((var_lit^1) / keys) } + local var_braced = lpeg.P { (lpeg.P("${") / "") * ((var_lit^1) / keys) * (lpeg.P("}") / "") } - template_grammar = lpeg.Cs((var + var_braced + 1)^0) - end + local template_grammar = lpeg.Cs((var + var_braced + 1)^0) return lpeg.match(template_grammar, tmpl) end diff --git a/src/plugins/lua/metadata_exporter.lua b/src/plugins/lua/metadata_exporter.lua index 8d0778ad5..3c0e1b2dc 100644 --- a/src/plugins/lua/metadata_exporter.lua +++ b/src/plugins/lua/metadata_exporter.lua @@ -128,17 +128,14 @@ local function get_general_metadata(task, flatten, no_content) return r end -local template_grammar local function simple_template(tmpl, keys) local lpeg = require "lpeg" - if not template_grammar then - local var_lit = lpeg.P { lpeg.R("az") + lpeg.R("AZ") + lpeg.R("09") + "_" } - local var = lpeg.P { (lpeg.P("$") / "") * ((var_lit^1) / keys) } - local var_braced = lpeg.P { (lpeg.P("${") / "") * ((var_lit^1) / keys) * (lpeg.P("}") / "") } + local var_lit = lpeg.P { lpeg.R("az") + lpeg.R("AZ") + lpeg.R("09") + "_" } + local var = lpeg.P { (lpeg.P("$") / "") * ((var_lit^1) / keys) } + local var_braced = lpeg.P { (lpeg.P("${") / "") * ((var_lit^1) / keys) * (lpeg.P("}") / "") } - template_grammar = lpeg.Cs((var + var_braced + 1)^0) - end + local template_grammar = lpeg.Cs((var + var_braced + 1)^0) return lpeg.match(template_grammar, tmpl) end -- 2.39.5