From: Vsevolod Stakhov Date: Wed, 25 Sep 2019 17:33:48 +0000 (+0100) Subject: [Minor] Fix protocol encoding X-Git-Tag: 2.0~123 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=f3d09eddea1bc2f7a56db339a75cb66e61502c88;p=rspamd.git [Minor] Fix protocol encoding --- 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://");