]> source.dussan.org Git - rspamd.git/commitdiff
[Minor] Normalise backslashes to slashes in urls
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Fri, 20 Dec 2019 13:51:53 +0000 (13:51 +0000)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Fri, 20 Dec 2019 13:51:53 +0000 (13:51 +0000)
src/libserver/url.c

index 985df24ac8d82d3ad1162093a2443dca127fe170..9b1fa9309cc510763b01b2d12682355f3fd1ad01 100644 (file)
@@ -2124,6 +2124,21 @@ rspamd_url_parse (struct rspamd_url *uri,
                                }
                        }
                }
+
+               /* Replace stupid '\' with '/' after schema */
+               if (uri->protocol & (PROTOCOL_HTTP|PROTOCOL_HTTPS|PROTOCOL_FTP) &&
+                       uri->protocollen > 0 && uri->urllen > uri->protocollen + 2) {
+
+                       gchar *pos = &uri->string[uri->protocollen], *host_start = uri->host;
+
+                       while (pos < host_start) {
+                               if (*pos == '\\') {
+                                       *pos = '/';
+                                       uri->flags |= RSPAMD_URL_FLAG_OBSCURED;
+                               }
+                               pos ++;
+                       }
+               }
        }
        else if (uri->protocol & PROTOCOL_TELEPHONE) {
                /* We need to normalise phone number: remove all spaces and braces */