]> source.dussan.org Git - rspamd.git/commitdiff
[Minor] Fix protocol encoding
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Wed, 25 Sep 2019 17:33:48 +0000 (18:33 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Wed, 25 Sep 2019 17:33:48 +0000 (18:33 +0100)
src/libserver/url.c

index d770b2191faf72414cc811be45ce84e00a9a065a..ec43404f999ebae7bb13b24dedf0cbf6d5785823 100644 (file)
@@ -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://");