commit 4358f49: [Minor] It seems we still need raw urls...

Vsevolod Stakhov vsevolod at highsecure.ru
Wed Apr 14 15:21:05 UTC 2021


Author: Vsevolod Stakhov
Date: 2021-04-14 16:14:43 +0100
URL: https://github.com/rspamd/rspamd/commit/4358f493cc2365982c10e9c80e9a73bf5e6bc584 (HEAD -> master)

[Minor] It seems we still need raw urls...

---
 src/libserver/url.c |  3 +++
 src/libserver/url.h | 14 +++++++-------
 src/lua/lua_url.c   |  2 +-
 3 files changed, 11 insertions(+), 8 deletions(-)

diff --git a/src/libserver/url.c b/src/libserver/url.c
index fb4b4da94..01bb527f0 100644
--- a/src/libserver/url.c
+++ b/src/libserver/url.c
@@ -2225,6 +2225,9 @@ rspamd_url_parse (struct rspamd_url *uri,
 		len = end - uristring;
 	}
 
+	uri->raw = p;
+	uri->rawlen = len;
+
 	if (flags & RSPAMD_URL_FLAG_MISSINGSLASHES) {
 		len += 2;
 		uri->string = rspamd_mempool_alloc (pool, len + 1);
diff --git a/src/libserver/url.h b/src/libserver/url.h
index 0a36ca17b..fe3124308 100644
--- a/src/libserver/url.h
+++ b/src/libserver/url.h
@@ -45,26 +45,26 @@ struct rspamd_url_tag {
 	struct rspamd_url_tag *prev, *next;
 };
 
+
 struct rspamd_url {
 	gchar *string;
+	gchar *raw;
 
 	gchar *visible_part;
 	struct rspamd_url *phished_url;
 
 	guint32 flags;
 
-	guint16 protocol;
-	guint16 protocollen;
-	guint16 port;
+	guint8 protocol;
+	guint8 protocollen;
 
+	guint16 port;
 	guint16 usershift;
 	guint16 hostshift;
 	guint16 datashift;
 	guint16 queryshift;
 	guint16 fragmentshift;
 	guint16 tldshift;
-
-
 	guint16 userlen;
 	guint16 hostlen;
 	guint16 datalen;
@@ -72,8 +72,8 @@ struct rspamd_url {
 	guint16 fragmentlen;
 	guint16 tldlen;
 	guint16 count;
-
 	guint16 urllen;
+	guint16 rawlen;
 };
 
 #define rspamd_url_user(u) ((u)->userlen > 0 ? (u)->string + (u)->usershift : NULL)
@@ -106,7 +106,7 @@ enum rspamd_url_protocol {
 	PROTOCOL_HTTPS = 1u << 3u,
 	PROTOCOL_MAILTO = 1u << 4u,
 	PROTOCOL_TELEPHONE = 1u << 5u,
-	PROTOCOL_UNKNOWN = 1u << 15u,
+	PROTOCOL_UNKNOWN = 1u << 7u,
 };
 
 enum rspamd_url_parse_flags {
diff --git a/src/lua/lua_url.c b/src/lua/lua_url.c
index d77d4b27d..c2dade139 100644
--- a/src/lua/lua_url.c
+++ b/src/lua/lua_url.c
@@ -348,7 +348,7 @@ lua_url_get_raw (lua_State *L)
 	struct rspamd_lua_url *url = lua_check_url (L, 1);
 
 	if (url != NULL) {
-		lua_pushlstring (L, url->url->string, url->url->urllen);
+		lua_pushlstring (L, url->url->raw, url->url->rawlen);
 	}
 	else {
 		lua_pushnil (L);


More information about the Commits mailing list