libs/web: expose cbi map redirect property to page templates
[oweals/luci.git] / libs / web / luasrc / dispatcher.lua
index 451476202d456cd8fd6ce8e6861af0c4e073317e..d10b5c0b5f37eadca317ef447f43eeb353a88a33 100644 (file)
@@ -64,7 +64,7 @@ function build_url(...)
 
        local p
        for _, p in ipairs(path) do
-               if p:match("^[a-zA-Z0-9_%-%./,;]+$") then
+               if p:match("^[a-zA-Z0-9_%-%.%%/,;]+$") then
                        url[#url+1] = "/"
                        url[#url+1] = p
                end
@@ -718,6 +718,7 @@ local function _cbi(self, ...)
                end
        end
 
+       local redirect
        local pageaction = true
        http.header("X-CBI-State", state or 0)
        if not config.noheader then
@@ -728,9 +729,18 @@ local function _cbi(self, ...)
                if res.pageaction == false then
                        pageaction = false
                end
+               if res.redirect then
+                       redirect = redirect or res.redirect
+               end
        end
        if not config.nofooter then
-               tpl.render("cbi/footer", {flow = config, pageaction=pageaction, state = state, autoapply = config.autoapply})
+               tpl.render("cbi/footer", {
+                       flow       = config,
+                       pageaction = pageaction,
+                       redirect   = redirect,
+                       state      = state,
+                       autoapply  = config.autoapply
+               })
        end
 end