]> source.dussan.org Git - rspamd.git/commitdiff
Fix wrongly placed g_string_free.
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Wed, 16 Sep 2015 17:03:08 +0000 (18:03 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Wed, 16 Sep 2015 17:03:08 +0000 (18:03 +0100)
src/lua/lua_common.c
src/plugins/lua/whitelist.lua

index bea2f0a5815b322c408cf5a79d629b595c55e41c..519c49dede7e791711cc4a4c1e59def30143cc12 100644 (file)
@@ -312,7 +312,6 @@ rspamd_init_lua_filters (struct rspamd_config *cfg)
                                msg_err_config ("load of %s failed: %s", module->path,
                                        lua_tostring (L, -1));
                                cur = g_list_next (cur);
-                               g_string_free (tb, TRUE);
                                lua_pop (L, 1); /*  Error function */
                                continue;
                        }
index 74be5dbfe9e5bbc23b4837956ddf5e189dc0f274..b7718636e7b72581c2ed093a5c4b3f75f1a32542 100644 (file)
@@ -25,6 +25,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 ]]--
 
 local rspamd_logger = require "rspamd_logger"
+local rspamd_url = require "rspamd_url"
 local ucl = require "ucl"
 require "fun" ()
 
@@ -40,9 +41,19 @@ local function whitelist_cb(symbol, rule, task)
   local from = task:get_from(1)
   if from and from[1] and from[1]['domain'] then
     local domain = from[1]['domain']
+    local url_domain = rspamd_url.create('http://' .. domain)
     local found = false
     local mult = 1.0
 
+    if url_domain then
+      -- Get tld + 1 component
+      local tld = url_domain:get_tld()
+      local host = url_domain:get_host()
+
+      domain = string.match(host, string.format('[^.].%s$', tld)
+      rspamd_logger.errx(domain)
+    end
+
     if rule['map'] then
       local val = rule['map']:get_key(domain)
       if val then