diff options
author | Vsevolod Stakhov <vsevolod@rspamd.com> | 2023-08-09 17:31:04 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@rspamd.com> | 2023-08-09 17:32:36 +0100 |
commit | d8e47a12ae221b2e79dbd786ccfa0402cff0c49b (patch) | |
tree | 727b034d73dee66be3ea760e27493f0d28293f96 /src/lua | |
parent | 1f9ec9e844bfd53974870734fa237cc059808c28 (diff) | |
download | rspamd-d8e47a12ae221b2e79dbd786ccfa0402cff0c49b.tar.gz rspamd-d8e47a12ae221b2e79dbd786ccfa0402cff0c49b.zip |
[Fix] Fix `url:set_redirected` method
Diffstat (limited to 'src/lua')
-rw-r--r-- | src/lua/lua_url.c | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/src/lua/lua_url.c b/src/lua/lua_url.c index 3f25b3128..913469f6d 100644 --- a/src/lua/lua_url.c +++ b/src/lua/lua_url.c @@ -1,11 +1,11 @@ -/*- - * Copyright 2016 Vsevolod Stakhov +/* + * Copyright 2023 Vsevolod Stakhov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, @@ -500,10 +500,10 @@ lua_url_get_phished(lua_State *L) } /*** - * @method url:set_redirected(url,[ pool]) + * @method url:set_redirected(url, pool) * Set url as redirected to another url * @param {string|url} url new url that is redirecting an old one - * @param {pool} pool if url is a string this is required for parsing + * @param {pool} pool memory pool to allocate memory if needed * @return {url} parsed redirected url (if needed) */ static gint @@ -557,6 +557,12 @@ lua_url_set_redirected(lua_State *L) return luaL_error(L, "url is required as the second argument"); } + pool = rspamd_lua_check_mempool(L, 3); + + if (pool == NULL) { + return luaL_error(L, "mempool is required as the third argument"); + } + url->url->flags |= RSPAMD_URL_FLAG_REDIRECTED; if (url->url->ext == NULL) { url->url->ext = rspamd_mempool_alloc0_type(pool, struct rspamd_url_ext); |