From b95406c413b9f91fd8bdf2b386c8e9edf525dedb Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Thu, 5 Jan 2017 17:39:15 +0100 Subject: mod_register: Allow 'title' and 'instructions' fields to be customized --- plugins/mod_register.lua | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/plugins/mod_register.lua b/plugins/mod_register.lua index c376117f..f89efe20 100644 --- a/plugins/mod_register.lua +++ b/plugins/mod_register.lua @@ -41,16 +41,21 @@ local field_map = { date = { name = "date", type = "text-single", label = "Birth date" }; }; +local title = module:get_option_string("registration_title", + "Creating a new account"); +local instructions = module:get_option_string("registration_instructions", + "Choose a username and password for use with this service."); + local registration_form = dataform_new{ - title = "Creating a new account"; - instructions = "Choose a username and password for use with this service."; + title = title; + instructions = instructions; field_map.username; field_map.password; }; local registration_query = st.stanza("query", {xmlns = "jabber:iq:register"}) - :tag("instructions"):text("Choose a username and password for use with this service."):up() + :tag("instructions"):text(instructions):up() :tag("username"):up() :tag("password"):up(); -- cgit v1.2.3 From 43cc8f2d9de3fbe5fca99ed7980b921e06c683a4 Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Fri, 6 Jan 2017 11:10:24 +0100 Subject: util.dependencies: Update Debian package names for liblua5.1-lib0 -> lua-lib transition --- util/dependencies.lua | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/util/dependencies.lua b/util/dependencies.lua index d2024c4f..5d8446da 100644 --- a/util/dependencies.lua +++ b/util/dependencies.lua @@ -61,7 +61,7 @@ local function check_dependencies() if not lxp then missingdep("luaexpat", { - ["Debian/Ubuntu"] = "sudo apt-get install liblua5.1-expat0"; + ["Debian/Ubuntu"] = "sudo apt-get install lua-expat"; ["luarocks"] = "luarocks install luaexpat"; ["Source"] = "http://matthewwild.co.uk/projects/luaexpat/"; }); @@ -72,7 +72,7 @@ local function check_dependencies() if not socket then missingdep("luasocket", { - ["Debian/Ubuntu"] = "sudo apt-get install liblua5.1-socket2"; + ["Debian/Ubuntu"] = "sudo apt-get install lua-socket"; ["luarocks"] = "luarocks install luasocket"; ["Source"] = "http://www.tecgraf.puc-rio.br/~diego/professional/luasocket/"; }); @@ -83,7 +83,7 @@ local function check_dependencies() if not lfs then missingdep("luafilesystem", { ["luarocks"] = "luarocks install luafilesystem"; - ["Debian/Ubuntu"] = "sudo apt-get install liblua5.1-filesystem0"; + ["Debian/Ubuntu"] = "sudo apt-get install lua-filesystem"; ["Source"] = "http://www.keplerproject.org/luafilesystem/"; }); fatal = true; -- cgit v1.2.3 From 56f3c13d17b6e98923bc914cc51ed95527ea0b55 Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Fri, 6 Jan 2017 13:07:22 +0100 Subject: mod_register: Strip '+' char from field names without using length --- plugins/mod_register.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/mod_register.lua b/plugins/mod_register.lua index f89efe20..7a57d65b 100644 --- a/plugins/mod_register.lua +++ b/plugins/mod_register.lua @@ -64,7 +64,7 @@ for _, field in ipairs(additional_fields) do registration_form[#registration_form + 1] = field; else if field:match("%+$") then - field = field:sub(1, #field - 1); + field = field:sub(1, -2); field_map[field].required = true; end -- cgit v1.2.3 From c29639e0db4b023bbebe3d6e134c52761a74d1a1 Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Fri, 6 Jan 2017 13:09:09 +0100 Subject: mod_register: Verify that fields are known to prevent traceback --- plugins/mod_register.lua | 3 +++ 1 file changed, 3 insertions(+) diff --git a/plugins/mod_register.lua b/plugins/mod_register.lua index 7a57d65b..9358eb64 100644 --- a/plugins/mod_register.lua +++ b/plugins/mod_register.lua @@ -63,6 +63,7 @@ for _, field in ipairs(additional_fields) do if type(field) == "table" then registration_form[#registration_form + 1] = field; else + elseif field_map[field] or field_map[field:sub(1, -2) then if field:match("%+$") then field = field:sub(1, -2); field_map[field].required = true; @@ -70,6 +71,8 @@ for _, field in ipairs(additional_fields) do registration_form[#registration_form + 1] = field_map[field]; registration_query:tag(field):up(); + else + module:log("error", "Unknown field %q", field); end end registration_query:add_child(registration_form:form()); -- cgit v1.2.3 From ef391bf6c46128a67c5cb408496ea51b6f0d3736 Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Fri, 6 Jan 2017 13:14:17 +0100 Subject: mod_register: Fix syntax errors --- plugins/mod_register.lua | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/plugins/mod_register.lua b/plugins/mod_register.lua index 9358eb64..ee3f88ba 100644 --- a/plugins/mod_register.lua +++ b/plugins/mod_register.lua @@ -62,8 +62,7 @@ local registration_query = st.stanza("query", {xmlns = "jabber:iq:register"}) for _, field in ipairs(additional_fields) do if type(field) == "table" then registration_form[#registration_form + 1] = field; - else - elseif field_map[field] or field_map[field:sub(1, -2) then + elseif field_map[field] or field_map[field:sub(1, -2)] then if field:match("%+$") then field = field:sub(1, -2); field_map[field].required = true; -- cgit v1.2.3 From 5b10d245e368cd54f33928665b282462a52fd5d8 Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Sun, 8 Jan 2017 14:21:08 +0100 Subject: util-src: Make C modules assert that the Lua runtime matches what it was compiled for --- util-src/crand.c | 3 +++ util-src/encodings.c | 3 +++ util-src/hashes.c | 3 +++ util-src/net.c | 3 +++ util-src/pposix.c | 3 +++ util-src/ringbuffer.c | 3 +++ util-src/signal.c | 3 +++ util-src/table.c | 3 +++ util-src/windows.c | 3 +++ 9 files changed, 27 insertions(+) diff --git a/util-src/crand.c b/util-src/crand.c index fbdec8f8..177511ce 100644 --- a/util-src/crand.c +++ b/util-src/crand.c @@ -130,6 +130,9 @@ int Lseed(lua_State *L) { #endif int luaopen_util_crand(lua_State *L) { +#if (LUA_VERSION_NUM > 501) + luaL_checkversion(L); +#endif lua_newtable(L); lua_pushcfunction(L, Lrandom); lua_setfield(L, -2, "bytes"); diff --git a/util-src/encodings.c b/util-src/encodings.c index 35677095..6389b2be 100644 --- a/util-src/encodings.c +++ b/util-src/encodings.c @@ -524,6 +524,9 @@ static const luaL_Reg Reg_idna[] = { /***************** end *****************/ LUALIB_API int luaopen_util_encodings(lua_State* L) { +#if (LUA_VERSION_NUM > 501) + luaL_checkversion(L); +#endif #ifdef USE_STRINGPREP_ICU init_icu(); #endif diff --git a/util-src/hashes.c b/util-src/hashes.c index ecab2e32..d6f848c7 100644 --- a/util-src/hashes.c +++ b/util-src/hashes.c @@ -212,6 +212,9 @@ static const luaL_Reg Reg[] = { }; LUALIB_API int luaopen_util_hashes(lua_State* L) { +#if (LUA_VERSION_NUM > 501) + luaL_checkversion(L); +#endif lua_newtable(L); luaL_setfuncs(L, Reg, 0);; lua_pushliteral(L, "-3.14"); diff --git a/util-src/net.c b/util-src/net.c index 3ccc7618..18f3d27a 100644 --- a/util-src/net.c +++ b/util-src/net.c @@ -125,6 +125,9 @@ static int lc_local_addresses(lua_State* L) { } int luaopen_util_net(lua_State* L) { +#if (LUA_VERSION_NUM > 501) + luaL_checkversion(L); +#endif luaL_Reg exports[] = { { "local_addresses", lc_local_addresses }, { NULL, NULL } diff --git a/util-src/pposix.c b/util-src/pposix.c index 7037730f..39d8742b 100644 --- a/util-src/pposix.c +++ b/util-src/pposix.c @@ -779,6 +779,9 @@ int lc_fallocate(lua_State* L) { /* Register functions */ int luaopen_util_pposix(lua_State* L) { +#if (LUA_VERSION_NUM > 501) + luaL_checkversion(L); +#endif luaL_Reg exports[] = { { "abort", lc_abort }, diff --git a/util-src/ringbuffer.c b/util-src/ringbuffer.c index f5fa136b..d60a43d9 100644 --- a/util-src/ringbuffer.c +++ b/util-src/ringbuffer.c @@ -197,6 +197,9 @@ int rb_gc(lua_State* L) { } int luaopen_util_ringbuffer(lua_State* L) { +#if (LUA_VERSION_NUM > 501) + luaL_checkversion(L); +#endif if(luaL_newmetatable(L, "ringbuffer_mt")) { lua_pushcfunction(L, rb_tostring); lua_setfield(L, -2, "__tostring"); diff --git a/util-src/signal.c b/util-src/signal.c index 725555fa..3f29febb 100644 --- a/util-src/signal.c +++ b/util-src/signal.c @@ -384,6 +384,9 @@ static const struct luaL_Reg lsignal_lib[] = { }; int luaopen_util_signal(lua_State* L) { +#if (LUA_VERSION_NUM > 501) + luaL_checkversion(L); +#endif int i = 0; /* add the library */ diff --git a/util-src/table.c b/util-src/table.c index 63415541..93acae65 100644 --- a/util-src/table.c +++ b/util-src/table.c @@ -21,6 +21,9 @@ static int Lpack(lua_State* L) { int luaopen_util_table(lua_State* L) { +#if (LUA_VERSION_NUM > 501) + luaL_checkversion(L); +#endif lua_newtable(L); lua_pushcfunction(L, Lcreate_table); lua_setfield(L, -2, "create"); diff --git a/util-src/windows.c b/util-src/windows.c index 4fcbf21e..e4457994 100644 --- a/util-src/windows.c +++ b/util-src/windows.c @@ -103,6 +103,9 @@ static const luaL_Reg Reg[] = { }; LUALIB_API int luaopen_util_windows(lua_State* L) { +#if (LUA_VERSION_NUM > 501) + luaL_checkversion(L); +#endif lua_newtable(L); luaL_setfuncs(L, Reg, 0); lua_pushliteral(L, "-3.14"); -- cgit v1.2.3 From d3f66c0848559e7f019aa50617052a0030f2df65 Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Mon, 9 Jan 2017 10:17:09 +0100 Subject: tools/erlparse: Remove use of deprecated module() function --- tools/erlparse.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/erlparse.lua b/tools/erlparse.lua index 25c38bcf..45bed265 100644 --- a/tools/erlparse.lua +++ b/tools/erlparse.lua @@ -189,9 +189,9 @@ local function readFile(filename) end; end -module "erlparse" +local _M = {}; -function parseFile(file) +function _M.parseFile(file) return readFile(file); end -- cgit v1.2.3