commit fe3cb3a: [Minor] Update lua-lupa

Andrew Lewis nerf at judo.za.org
Sun Jan 24 22:42:06 UTC 2021


Author: Andrew Lewis
Date: 2021-01-24 22:55:42 +0200
URL: https://github.com/rspamd/rspamd/commit/fe3cb3a530925750efc581483b03b48c5e565ab4 (refs/pull/3618/head)

[Minor] Update lua-lupa
 - Fixed bug where 'else' was not evaluated if 'elseif' is present.

---
 contrib/lua-lupa/lupa.lua | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/contrib/lua-lupa/lupa.lua b/contrib/lua-lupa/lupa.lua
index fc49ac258..adaf419ad 100644
--- a/contrib/lua-lupa/lupa.lua
+++ b/contrib/lua-lupa/lupa.lua
@@ -1,4 +1,4 @@
--- Copyright 2015-2019 Mitchell mitchell.att.foicica.com. See LICENSE.
+-- Copyright 2015-2020 Mitchell. See LICENSE.
 -- Sponsored by the Library of the University of Antwerp.
 -- Contributions from Ana Balan.
 -- Lupa templating engine.
@@ -457,15 +457,18 @@ local function evaluate(ast, env)
       if eval(block.expression, env) then
         chunks[#chunks + 1] = evaluate(block, env)
       else
+        local evaluate_else = true
         local elseifs = block['elseif']
         if elseifs then
           for j = 1, #elseifs do
             if eval(elseifs[j].expression, env) then
               chunks[#chunks + 1] = evaluate(elseifs[j], env)
+              evaluate_else = false
               break
             end
           end
-        elseif block['else'] then
+        end
+        if evaluate_else and block['else'] then
           chunks[#chunks + 1] = evaluate(block['else'], env)
         end
       end


More information about the Commits mailing list