commit 2623065: [Fix] Fix opaque maps logic

Vsevolod Stakhov vsevolod at highsecure.ru
Thu Feb 27 15:35:29 UTC 2020


Author: Vsevolod Stakhov
Date: 2020-02-27 15:33:04 +0000
URL: https://github.com/rspamd/rspamd/commit/2623065a8f9441f78c33466f847df77807a31230 (HEAD -> master)

[Fix] Fix opaque maps logic

---
 src/lua/lua_map.c            | 3 ++-
 src/plugins/lua/phishing.lua | 8 +++++---
 2 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/src/lua/lua_map.c b/src/lua/lua_map.c
index b279bacbd..a5defd011 100644
--- a/src/lua/lua_map.c
+++ b/src/lua/lua_map.c
@@ -444,13 +444,14 @@ lua_map_fin (struct map_cb_data *data, void **target)
 	else if (cbdata->data != NULL && cbdata->data->len != 0) {
 		lua_rawgeti (cbdata->L, LUA_REGISTRYINDEX, cbdata->ref);
 
-		if (cbdata->opaque) {
+		if (!cbdata->opaque) {
 			lua_pushlstring (cbdata->L, cbdata->data->str, cbdata->data->len);
 		}
 		else {
 			struct rspamd_lua_text *t;
 
 			t = lua_newuserdata (cbdata->L, sizeof (*t));
+			rspamd_lua_setclass (cbdata->L, "rspamd{text}", -1);
 			t->flags = 0;
 			t->len = cbdata->data->len;
 			t->start = cbdata->data->str;
diff --git a/src/plugins/lua/phishing.lua b/src/plugins/lua/phishing.lua
index e07cd8858..89d69cb5e 100644
--- a/src/plugins/lua/phishing.lua
+++ b/src/plugins/lua/phishing.lua
@@ -423,7 +423,7 @@ local function openphish_json_cb(string)
   pool:destroy()
 end
 
-local function openphish_plain_cb(string)
+local function openphish_plain_cb(s)
   local nelts = 0
   local new_data = {}
   local rspamd_mempool = require "rspamd_mempool"
@@ -435,7 +435,7 @@ local function openphish_plain_cb(string)
     end
   end
 
-  rspamd_str_split_fun(string, '\n', openphish_elt_parser)
+  rspamd_str_split_fun(s, '\n', openphish_elt_parser)
 
   openphish_data = new_data
   rspamd_logger.infox(openphish_hash, "parsed %s elements from openphish feed",
@@ -492,13 +492,15 @@ if opts then
           type = 'callback',
           url = openphish_map,
           callback = openphish_plain_cb,
-          description = 'Open phishing feed map (see https://www.openphish.com for details)'
+          description = 'Open phishing feed map (see https://www.openphish.com for details)',
+          opaque_data = true,
         })
       else
         openphish_hash = rspamd_config:add_map({
             type = 'callback',
             url = openphish_map,
             callback = openphish_json_cb,
+            opaque_data = true,
             description = 'Open phishing premium feed map (see https://www.openphish.com for details)'
           })
       end


More information about the Commits mailing list