commit 16f1222: [Minor] Preserve line endings when templating

Vsevolod Stakhov vsevolod at highsecure.ru
Wed Mar 27 16:42:03 UTC 2019


Author: Vsevolod Stakhov
Date: 2019-03-27 16:39:54 +0000
URL: https://github.com/rspamd/rspamd/commit/16f122266c71f8593026c16f14f91f913eec4e0d (HEAD -> master)

[Minor] Preserve line endings when templating

---
 lualib/lua_util.lua | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/lualib/lua_util.lua b/lualib/lua_util.lua
index 0ae18a22e..d32058547 100644
--- a/lualib/lua_util.lua
+++ b/lualib/lua_util.lua
@@ -23,6 +23,7 @@ local exports = {}
 local lpeg = require 'lpeg'
 local rspamd_util = require "rspamd_util"
 local fun = require "fun"
+local lupa = require "lupa"
 
 local split_grammar = {}
 local spaces_split_grammar
@@ -30,6 +31,10 @@ local space = lpeg.S' \t\n\v\f\r'
 local nospace = 1 - space
 local ptrim = space^0 * lpeg.C((space^0 * nospace^1)^0)
 local match = lpeg.match
+lupa.configure{
+  keep_trailing_newline = true,
+  autoescape = false,
+}
 
 local function rspamd_str_split(s, sep)
   local gr
@@ -132,8 +137,6 @@ end
 -- "HELLO LUA WORLD!"
 --]]
 exports.jinja_template = function(text, env, skip_global_env)
-  local lupa = require "lupa"
-
   if not skip_global_env then
     env = enrich_template_with_globals(env)
   end
@@ -153,8 +156,6 @@ end
 -- "HELLO LUA WORLD!"
 --]]
 exports.jinja_template_file = function(filename, env, skip_global_env)
-  local lupa = require "lupa"
-
   if not skip_global_env then
     env = enrich_template_with_globals(env)
   end


More information about the Commits mailing list