]> source.dussan.org Git - rspamd.git/commitdiff
[Rework] Rename phished url to a linked url
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Mon, 19 Apr 2021 16:14:06 +0000 (17:14 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Mon, 19 Apr 2021 16:14:06 +0000 (17:14 +0100)
src/libserver/html.c
src/libserver/protocol.c
src/libserver/url.c
src/libserver/url.h
src/lua/lua_url.c

index 137907183184e0639e2f26166ba100869e1eec69..4cb46445f85892cfac21bb257fe121e6893739c2 100644 (file)
@@ -819,7 +819,7 @@ rspamd_html_url_is_phished (rspamd_mempool_t *pool,
 
                                        if (!rspamd_url_is_subdomain (&disp_tok, &href_tok)) {
                                                href_url->flags |= RSPAMD_URL_FLAG_PHISHED;
-                                               href_url->phished_url = text_url;
+                                               href_url->linked_url = text_url;
                                                text_url->flags |= RSPAMD_URL_FLAG_HTML_DISPLAYED;
                                        }
                                }
index 7307c95c8489c54162b19bab2bd45b16f849fe4a..878f0bb3e979c3032df54811e877387febf3d2ad 100644 (file)
@@ -895,11 +895,11 @@ rspamd_protocol_extended_url (struct rspamd_task *task,
        elt = ucl_object_frombool (url->flags & RSPAMD_URL_FLAG_REDIRECTED);
        ucl_object_insert_key (obj, elt, "redirected", 0, false);
 
-       if (url->phished_url) {
-               encoded = rspamd_url_encode (url->phished_url, &enclen, task->task_pool);
-               elt = rspamd_protocol_extended_url (task, url->phished_url, encoded,
+       if (url->linked_url) {
+               encoded = rspamd_url_encode (url->linked_url, &enclen, task->task_pool);
+               elt = rspamd_protocol_extended_url (task, url->linked_url, encoded,
                                enclen);
-               ucl_object_insert_key (obj, elt, "orig_url", 0, false);
+               ucl_object_insert_key (obj, elt, "linked_url", 0, false);
        }
 
        return obj;
index 6f62702b3a0acc6b7f07218d2b8561251b97f09f..d36704e73e0be40d373de1ebfa2541e719e73c07 100644 (file)
@@ -243,6 +243,7 @@ struct rspamd_url_flag_name {
                {"content", RSPAMD_URL_FLAG_CONTENT, -1},
                {"no_tld", RSPAMD_URL_FLAG_NO_TLD, -1},
                {"truncated", RSPAMD_URL_FLAG_TRUNCATED, -1},
+               {"redirect_target", RSPAMD_URL_FLAG_REDIRECT_TARGET, -1},
 };
 
 
index 11177492d4abd867b22b409c14ca13634ecec45e..249c316e4240f7525443055d2e57b841c1c9b2c7 100644 (file)
@@ -39,8 +39,9 @@ enum rspamd_url_flags {
        RSPAMD_URL_FLAG_CONTENT = 1u << 21u,
        RSPAMD_URL_FLAG_NO_TLD = 1u << 22u,
        RSPAMD_URL_FLAG_TRUNCATED = 1u << 23u,
+       RSPAMD_URL_FLAG_REDIRECT_TARGET = 1u << 24u,
 };
-#define RSPAMD_URL_MAX_FLAG_SHIFT (24u)
+#define RSPAMD_URL_MAX_FLAG_SHIFT (25u)
 
 struct rspamd_url_tag {
        const gchar *data;
@@ -53,7 +54,7 @@ struct rspamd_url {
        gchar *raw;
 
        gchar *visible_part;
-       struct rspamd_url *phished_url;
+       struct rspamd_url *linked_url;
 
        guint32 flags;
 
index 0a0af8331c6b52309192521740df990c4ec537a8..ebb7e7534f2a4222e8b2bcc062c5902b88a9f23e 100644 (file)
@@ -475,12 +475,12 @@ lua_url_get_phished (lua_State *L)
        struct rspamd_lua_url *purl, *url = lua_check_url (L, 1);
 
        if (url) {
-               if (url->url->phished_url != NULL) {
+               if (url->url->linked_url != NULL) {
                        if (url->url->flags &
                                        (RSPAMD_URL_FLAG_PHISHED|RSPAMD_URL_FLAG_REDIRECTED)) {
                                purl = lua_newuserdata (L, sizeof (struct rspamd_lua_url));
                                rspamd_lua_setclass (L, "rspamd{url}", -1);
-                               purl->url = url->url->phished_url;
+                               purl->url = url->url->linked_url;
 
                                return 1;
                        }
@@ -535,7 +535,7 @@ lua_url_set_redirected (lua_State *L)
                        redir = lua_check_url (L, -1);
 
                        url->url->flags |= RSPAMD_URL_FLAG_REDIRECTED;
-                       url->url->phished_url = redir->url;
+                       url->url->linked_url = redir->url;
                }
        }
        else {
@@ -546,7 +546,7 @@ lua_url_set_redirected (lua_State *L)
                }
 
                url->url->flags |= RSPAMD_URL_FLAG_REDIRECTED;
-               url->url->phished_url = redir->url;
+               url->url->linked_url = redir->url;
 
                /* Push back on stack */
                lua_pushvalue (L, 2);
@@ -903,28 +903,9 @@ lua_url_get_flags (lua_State *L)
 
                lua_createtable (L, 0, 4);
 
-               PUSH_FLAG (RSPAMD_URL_FLAG_PHISHED);
-               PUSH_FLAG (RSPAMD_URL_FLAG_NUMERIC);
-               PUSH_FLAG (RSPAMD_URL_FLAG_OBSCURED);
-               PUSH_FLAG (RSPAMD_URL_FLAG_REDIRECTED);
-               PUSH_FLAG (RSPAMD_URL_FLAG_HTML_DISPLAYED);
-               PUSH_FLAG (RSPAMD_URL_FLAG_FROM_TEXT);
-               PUSH_FLAG (RSPAMD_URL_FLAG_SUBJECT);
-               PUSH_FLAG (RSPAMD_URL_FLAG_HOSTENCODED);
-               PUSH_FLAG (RSPAMD_URL_FLAG_SCHEMAENCODED);
-               PUSH_FLAG (RSPAMD_URL_FLAG_PATHENCODED);
-               PUSH_FLAG (RSPAMD_URL_FLAG_QUERYENCODED);
-               PUSH_FLAG (RSPAMD_URL_FLAG_MISSINGSLASHES);
-               PUSH_FLAG (RSPAMD_URL_FLAG_IDN);
-               PUSH_FLAG (RSPAMD_URL_FLAG_HAS_PORT);
-               PUSH_FLAG (RSPAMD_URL_FLAG_HAS_USER);
-               PUSH_FLAG (RSPAMD_URL_FLAG_SCHEMALESS);
-               PUSH_FLAG (RSPAMD_URL_FLAG_UNNORMALISED);
-               PUSH_FLAG (RSPAMD_URL_FLAG_ZW_SPACES);
-               PUSH_FLAG (RSPAMD_URL_FLAG_DISPLAY_URL);
-               PUSH_FLAG (RSPAMD_URL_FLAG_IMAGE);
-               PUSH_FLAG (RSPAMD_URL_FLAG_CONTENT);
-               PUSH_FLAG (RSPAMD_URL_FLAG_TRUNCATED);
+               for (gint i = 0; i < RSPAMD_URL_MAX_FLAG_SHIFT; i ++) {
+                       PUSH_FLAG (1u << i);
+               }
        }
        else {
                return luaL_error (L, "invalid arguments");