From: Vsevolod Stakhov Date: Sat, 12 Nov 2022 15:17:45 +0000 (+0000) Subject: [Project] Add query encoding usage X-Git-Tag: 3.5~204^2~13 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3ec55e1bcb675fb2affcd4977e9517054c9a5342;p=thirdparty%2Frspamd.git [Project] Add query encoding usage --- diff --git a/lualib/lua_maps.lua b/lualib/lua_maps.lua index b2f8dda923..88f0b894ae 100644 --- a/lualib/lua_maps.lua +++ b/lualib/lua_maps.lua @@ -141,7 +141,13 @@ local function query_external_map(map_config, upstreams, key, callback, task) else -- query/header and no encode if map_config.method == 'query' then - -- TODO: encode key/value pairs into query params + local params_table = {} + for k,v in pairs(key) do + if type(v) == 'string' then + table.insert(params_table, string.format('%s=%s', url_encode_string(k), url_encode_string(v))) + end + end + url = string.format('%s?%s', url, table.concat(params_table, '&')) elseif map_config.method == 'header' then http_headers = key else @@ -150,7 +156,6 @@ local function query_external_map(map_config, upstreams, key, callback, task) "requested external map key with a wrong combination of encode and input; caller: %s:%s", caller.short_src, caller.currentline) callback(false, 'invalid map usage', 500, task) - return end end