From: Vsevolod Stakhov Date: Wed, 27 Mar 2019 16:39:54 +0000 (+0000) Subject: [Minor] Preserve line endings when templating X-Git-Tag: 1.9.1~33 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=16f122266c71f8593026c16f14f91f913eec4e0d;p=rspamd.git [Minor] Preserve line endings when templating --- 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