Merge pull request #33 from crowdsecurity/fix_empty_ret_code
Fix empty ret_code behavior and empty line in config
This commit is contained in:
commit
57bfc35500
2 changed files with 10 additions and 2 deletions
|
@ -22,8 +22,8 @@ function M.new(template_path, redirect_location, ret_code)
|
|||
end
|
||||
end
|
||||
|
||||
if ret_code_ok == false then
|
||||
ngx.log(ngx.ERR, "RET_CODE '" .. ret_code .. "' is not supported")
|
||||
if ret_code_ok == false and ret_code ~= 0 and ret_code ~= "" then
|
||||
ngx.log(ngx.ERR, "RET_CODE '" .. ret_code .. "' is not supported, using default HTTP code " .. M.ret_code)
|
||||
end
|
||||
|
||||
template_file_ok = false
|
||||
|
|
|
@ -30,6 +30,11 @@ local function starts_with(str, start)
|
|||
return str:sub(1, #start) == start
|
||||
end
|
||||
|
||||
local function trim(s)
|
||||
return (string.gsub(s, "^%s*(.-)%s*$", "%1"))
|
||||
end
|
||||
|
||||
|
||||
function config.loadConfig(file)
|
||||
if not config.file_exists(file) then
|
||||
return nil, "File ".. file .." doesn't exist"
|
||||
|
@ -55,6 +60,9 @@ function config.loadConfig(file)
|
|||
if starts_with(line, "#") then
|
||||
isOk = true
|
||||
end
|
||||
if trim(line) == "" then
|
||||
isOk = true
|
||||
end
|
||||
if not isOk then
|
||||
local s = split(line, "=")
|
||||
for k, v in pairs(s) do
|
||||
|
|
Loading…
Reference in a new issue