aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@rspamd.com>2024-02-12 15:07:30 +0000
committerVsevolod Stakhov <vsevolod@rspamd.com>2024-02-12 15:07:30 +0000
commitc6514d44c8818c03c2f4a3d0c1097730c4561e63 (patch)
tree808d1c03b968357b916012555093bd28abc791ff
parent52d1dfb9acf71bd962cb3fe836818efb09dc1cc3 (diff)
downloadrspamd-c6514d44c8818c03c2f4a3d0c1097730c4561e63.tar.gz
rspamd-c6514d44c8818c03c2f4a3d0c1097730c4561e63.zip
[Minor] Slightly improve log message
-rw-r--r--src/lua/lua_url.c51
1 files changed, 27 insertions, 24 deletions
diff --git a/src/lua/lua_url.c b/src/lua/lua_url.c
index 20f0a7121..c09eedea6 100644
--- a/src/lua/lua_url.c
+++ b/src/lua/lua_url.c
@@ -858,38 +858,41 @@ lua_url_create(lua_State *L)
}
else {
pool = static_lua_url_pool;
- t = lua_check_text_or_string(L, 2);
+ t = lua_check_text_or_string(L, 1);
}
- if (pool == NULL || t == NULL) {
- return luaL_error(L, "invalid arguments");
+ if (pool == NULL) {
+ return luaL_error(L, "invalid arguments: mempool is expected as the second argument");
}
- else {
- rspamd_url_find_single(pool, t->start, t->len, RSPAMD_URL_FIND_ALL,
- lua_url_single_inserter, L);
- if (lua_type(L, -1) != LUA_TUSERDATA) {
- /* URL is actually not found */
- lua_pushnil(L);
+ if (t == NULL) {
+ return luaL_error(L, "invalid arguments: string/text is expected as the first argument");
+ }
- return 1;
- }
+ rspamd_url_find_single(pool, t->start, t->len, RSPAMD_URL_FIND_ALL,
+ lua_url_single_inserter, L);
- u = (struct rspamd_lua_url *) lua_touserdata(L, -1);
+ if (lua_type(L, -1) != LUA_TUSERDATA) {
+ /* URL is actually not found */
+ lua_pushnil(L);
- if (lua_type(L, 3) == LUA_TTABLE) {
- /* Add flags */
- for (lua_pushnil(L); lua_next(L, 3); lua_pop(L, 1)) {
- int nmask = 0;
- const gchar *fname = lua_tostring(L, -1);
+ return 1;
+ }
- if (rspamd_url_flag_from_string(fname, &nmask)) {
- u->url->flags |= nmask;
- }
- else {
- lua_pop(L, 1);
- return luaL_error(L, "invalid flag: %s", fname);
- }
+ u = (struct rspamd_lua_url *) lua_touserdata(L, -1);
+
+ if (lua_type(L, 3) == LUA_TTABLE) {
+ /* Add flags */
+ for (lua_pushnil(L); lua_next(L, 3); lua_pop(L, 1)) {
+ int nmask = 0;
+ const gchar *fname = lua_tostring(L, -1);
+
+ if (rspamd_url_flag_from_string(fname, &nmask)) {
+ u->url->flags |= nmask;
+ }
+ else {
+ lua_pop(L, 1);
+ return luaL_error(L, "invalid flag: %s", fname);
}
}
}