commit f3d09ed: [Minor] Fix protocol encoding

Vsevolod Stakhov vsevolod at highsecure.ru
Wed Sep 25 17:35:06 UTC 2019


Author: Vsevolod Stakhov
Date: 2019-09-25 18:33:48 +0100
URL: https://github.com/rspamd/rspamd/commit/f3d09eddea1bc2f7a56db339a75cb66e61502c88 (HEAD -> master)

[Minor] Fix protocol encoding

---
 src/libserver/url.c | 17 ++++++++++++-----
 1 file changed, 12 insertions(+), 5 deletions(-)

diff --git a/src/libserver/url.c b/src/libserver/url.c
index d770b2191..ec43404f9 100644
--- a/src/libserver/url.c
+++ b/src/libserver/url.c
@@ -3487,16 +3487,23 @@ rspamd_url_encode (struct rspamd_url *url, gsize *pdlen,
 	}
 
 	/* Need to encode */
-	dlen += url->urllen;
+	dlen += url->urllen + sizeof ("telephone://"); /* Protocol hack */
 	dest = rspamd_mempool_alloc (pool, dlen + 1);
 	d = dest;
 	dend = d + dlen;
 
 	if (url->protocollen > 0) {
-		const gchar *known_proto = rspamd_url_protocol_name (url->protocol);
-		d += rspamd_snprintf ((gchar *) d, dend - d,
-				"%s://",
-				known_proto);
+		if (!(url->protocol & PROTOCOL_UNKNOWN)) {
+			const gchar *known_proto = rspamd_url_protocol_name (url->protocol);
+			d += rspamd_snprintf ((gchar *) d, dend - d,
+					"%s://",
+					known_proto);
+		}
+		else {
+			d += rspamd_snprintf ((gchar *) d, dend - d,
+					"%*s://",
+					(gint)url->protocollen, url->string);
+		}
 	}
 	else {
 		d += rspamd_snprintf ((gchar *) d, dend - d, "http://");


More information about the Commits mailing list