diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2020-03-07 16:32:14 +0000 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2020-03-09 10:46:11 +0000 |
commit | 5cb7a60c653914d09fd7a83bf4838a97b0d664d5 (patch) | |
tree | e254a7c5f39105b262852352f362cc8cedf059a9 /src/libserver/url.c | |
parent | 50a043a7cbce8142d81b7887d263a9573ff568eb (diff) | |
download | rspamd-5cb7a60c653914d09fd7a83bf4838a97b0d664d5.tar.gz rspamd-5cb7a60c653914d09fd7a83bf4838a97b0d664d5.zip |
[Rework] Urls: adopt html related stuff
Diffstat (limited to 'src/libserver/url.c')
-rw-r--r-- | src/libserver/url.c | 58 |
1 files changed, 45 insertions, 13 deletions
diff --git a/src/libserver/url.c b/src/libserver/url.c index 505d1d150..39ea5acc2 100644 --- a/src/libserver/url.c +++ b/src/libserver/url.c @@ -3297,7 +3297,7 @@ rspamd_url_task_subject_callback (struct rspamd_url *url, gsize start_offset, { struct rspamd_task *task = ud; gchar *url_str = NULL; - struct rspamd_url *query_url, *existing; + struct rspamd_url *query_url; gint rc; gboolean prefix_added; @@ -3781,6 +3781,26 @@ rspamd_url_set_add_or_increase (khash_t (rspamd_url_hash) *set, return true; } +struct rspamd_url * +rspamd_url_set_add_or_return (khash_t (rspamd_url_hash) *set, + struct rspamd_url *u) +{ + khiter_t k; + gint r; + + if (set) { + k = kh_put (rspamd_url_hash, set, u, &r); + + if (r == 0) { + struct rspamd_url *ex = kh_key (set, k); + + return ex; + } + } + + return NULL; +} + bool rspamd_url_host_set_add (khash_t (rspamd_url_host_hash) *set, struct rspamd_url *u) @@ -3788,13 +3808,17 @@ rspamd_url_host_set_add (khash_t (rspamd_url_host_hash) *set, khiter_t k; gint r; - k = kh_put (rspamd_url_host_hash, set, u, &r); + if (set) { + k = kh_put (rspamd_url_host_hash, set, u, &r); - if (r == 0) { - return false; + if (r == 0) { + return false; + } + + return true; } - return true; + return false; } bool @@ -3802,13 +3826,17 @@ rspamd_url_set_has (khash_t (rspamd_url_hash) *set, struct rspamd_url *u) { khiter_t k; - k = kh_get (rspamd_url_hash, set, u); + if (set) { + k = kh_get (rspamd_url_hash, set, u); - if (k == kh_end (set)) { - return false; + if (k == kh_end (set)) { + return false; + } + + return true; } - return true; + return false; } bool @@ -3816,11 +3844,15 @@ rspamd_url_host_set_has (khash_t (rspamd_url_host_hash) *set, struct rspamd_url { khiter_t k; - k = kh_get (rspamd_url_hash, set, u); + if (set) { + k = kh_get (rspamd_url_host_hash, set, u); - if (k == kh_end (set)) { - return false; + if (k == kh_end (set)) { + return false; + } + + return true; } - return true; + return false; }
\ No newline at end of file |