commit c489185: [Rework] Rename phished url to a linked url
Vsevolod Stakhov
vsevolod at highsecure.ru
Mon Apr 19 16:28:04 UTC 2021
Author: Vsevolod Stakhov
Date: 2021-04-19 17:14:06 +0100
URL: https://github.com/rspamd/rspamd/commit/c4891851bf1afba6ddc9da8539c2ac2996522660
[Rework] Rename phished url to a linked url
---
src/libserver/html.c | 2 +-
src/libserver/protocol.c | 8 ++++----
src/libserver/url.c | 1 +
src/libserver/url.h | 5 +++--
src/lua/lua_url.c | 33 +++++++--------------------------
5 files changed, 16 insertions(+), 33 deletions(-)
diff --git a/src/libserver/html.c b/src/libserver/html.c
index 137907183..4cb46445f 100644
--- a/src/libserver/html.c
+++ b/src/libserver/html.c
@@ -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;
}
}
diff --git a/src/libserver/protocol.c b/src/libserver/protocol.c
index 7307c95c8..878f0bb3e 100644
--- a/src/libserver/protocol.c
+++ b/src/libserver/protocol.c
@@ -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;
diff --git a/src/libserver/url.c b/src/libserver/url.c
index 6f62702b3..d36704e73 100644
--- a/src/libserver/url.c
+++ b/src/libserver/url.c
@@ -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},
};
diff --git a/src/libserver/url.h b/src/libserver/url.h
index 11177492d..249c316e4 100644
--- a/src/libserver/url.h
+++ b/src/libserver/url.h
@@ -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;
diff --git a/src/lua/lua_url.c b/src/lua/lua_url.c
index 0a0af8331..ebb7e7534 100644
--- a/src/lua/lua_url.c
+++ b/src/lua/lua_url.c
@@ -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");
More information about the Commits
mailing list