diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2017-03-27 10:01:56 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2017-03-27 10:01:56 +0100 |
commit | 7522631b4a5d98a7a38429716f0e56286c7d3c2c (patch) | |
tree | 2bda6d806cc817228d9ea8c626870412a6ccbf2b /src/plugins | |
parent | ad6158684c8ca07d105f3ffefc8124332a08e67f (diff) | |
download | rspamd-7522631b4a5d98a7a38429716f0e56286c7d3c2c.tar.gz rspamd-7522631b4a5d98a7a38429716f0e56286c7d3c2c.zip |
[Fix] Fix templates grammar usage
Diffstat (limited to 'src/plugins')
-rw-r--r-- | src/plugins/lua/dkim_signing.lua | 11 | ||||
-rw-r--r-- | 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 |