commit 3ec55e1: [Project] Add query encoding usage

Vsevolod Stakhov vsevolod at rspamd.com
Sat Nov 19 20:28:14 UTC 2022


Author: Vsevolod Stakhov
Date: 2022-11-12 15:17:45 +0000
URL: https://github.com/rspamd/rspamd/commit/3ec55e1bcb675fb2affcd4977e9517054c9a5342

[Project] Add query encoding usage

---
 lualib/lua_maps.lua | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/lualib/lua_maps.lua b/lualib/lua_maps.lua
index b2f8dda92..88f0b894a 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


More information about the Commits mailing list