From 8dc300fc2cc5a0df82d59bf4f6b3e7b0e2e79bdf Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Tue, 5 Nov 2013 22:38:03 +0000 Subject: [PATCH] Fix work with lua 5.2 eventually. --- CMakeLists.txt | 4 ++-- src/lua/lua_common.h | 4 +++- src/plugins/lua/multimap.lua | 2 +- src/plugins/lua/phishing.lua | 4 ++-- 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7bac51678..e558c93e5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -453,9 +453,9 @@ ENDIF(NOT LOCALSTATES_PREFIX) # Now find libraries and headers # Find lua libraries -FindLua(5 1) +FindLua(5 2) IF(NOT LUA_FOUND) - FindLua(5 2) + FindLua(5 1) ENDIF(NOT LUA_FOUND) IF(NOT LUA_FOUND) diff --git a/src/lua/lua_common.h b/src/lua/lua_common.h index e2e2f032a..fd4058c11 100644 --- a/src/lua/lua_common.h +++ b/src/lua/lua_common.h @@ -23,7 +23,9 @@ static inline void luaL_register (lua_State *L, const gchar *name, const struct luaL_reg *methods) { - lua_newtable (L); + if (name != NULL) { + lua_newtable (L); + } luaL_setfuncs (L, methods, 0); if (name != NULL) { lua_pushvalue (L, -1); diff --git a/src/plugins/lua/multimap.lua b/src/plugins/lua/multimap.lua index 0366d4843..078c00bc0 100644 --- a/src/plugins/lua/multimap.lua +++ b/src/plugins/lua/multimap.lua @@ -14,7 +14,7 @@ function split(str, delim, maxNb) local pat = "(.-)" .. delim .. "()" local nb = 0 local lastPos - for part, pos in string.gfind(str, pat) do + for part, pos in string.gmatch(str, pat) do nb = nb + 1 result[nb] = part lastPos = pos diff --git a/src/plugins/lua/phishing.lua b/src/plugins/lua/phishing.lua index 4d72ff806..ee66b9d91 100644 --- a/src/plugins/lua/phishing.lua +++ b/src/plugins/lua/phishing.lua @@ -14,7 +14,7 @@ function phishing_cb (task) local found = false local purl = url:get_phished() if table.maxn(strict_domains) > 0 then - local _,_,tld = string.find(purl:get_host(), '([a-zA-Z0-9%-]+\.[a-zA-Z0-9%-]+)$') + local _,_,tld = string.find(purl:get_host(), '([a-zA-Z0-9%-]+%.[a-zA-Z0-9%-]+)$') if tld then for _,rule in ipairs(strict_domains) do if rule['map']:get_key(tld) then @@ -26,7 +26,7 @@ function phishing_cb (task) end if not found then if domains then - local _,_,tld = string.find(purl:get_host(), '([a-zA-Z0-9%-]+\.[a-zA-Z0-9%-]+)$') + local _,_,tld = string.find(purl:get_host(), '([a-zA-Z0-9%-]+%.[a-zA-Z0-9%-]+)$') if tld then if domains:get_key(tld) then task:insert_result(symbol, 1, purl:get_host()) -- 2.39.5