]> source.dussan.org Git - rspamd.git/commitdiff
[Minor] Try to deal with urls with backslashes in path
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Fri, 30 Jul 2021 10:20:49 +0000 (11:20 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Fri, 30 Jul 2021 10:26:10 +0000 (11:26 +0100)
src/libserver/url.c
test/lua/unit/url.lua

index ce98f0961b029130adccb21fc23742b58dca59d0..139252df4e1618d8443ff295c91cf5dad60212a4 100644 (file)
@@ -1165,7 +1165,7 @@ rspamd_web_parse (struct http_parser_url *u, const gchar *str, gsize len,
                                        st = parse_port;
                                        c = p + 1;
                                }
-                               else if (*p == '/') {
+                               else if (*p == '/' || *p == '\\') {
                                        st = parse_path;
                                        c = p + 1;
                                }
@@ -1309,11 +1309,11 @@ rspamd_web_parse (struct http_parser_url *u, const gchar *str, gsize len,
                                /* Too large domain */
                                goto out;
                        }
-                       if (t == '/' || t == ':' || t == '?' || t == '#') {
+                       if (t == '/' || t == '\\' || t == ':' || t == '?' || t == '#') {
                                if (p - c == 0) {
                                        goto out;
                                }
-                               if (t == '/') {
+                               if (t == '/' || t == '\\') {
                                        SET_U (u, UF_HOST);
                                        st = parse_suffix_slash;
                                }
@@ -1463,7 +1463,7 @@ rspamd_web_parse (struct http_parser_url *u, const gchar *str, gsize len,
                        }
                        break;
                case parse_port:
-                       if (t == '/') {
+                       if (t == '/' || t == '\\') {
                                pt = strtoul (c, NULL, 10);
                                if (pt == 0 || pt > 65535) {
                                        goto out;
@@ -1515,7 +1515,7 @@ rspamd_web_parse (struct http_parser_url *u, const gchar *str, gsize len,
                        p++;
                        break;
                case parse_suffix_slash:
-                       if (t != '/') {
+                       if (t != '/' && t != '\\') {
                                c = p;
                                st = parse_path;
                        }
index 282d79290856780cad934cc3bf546b8d742b8ce3..58dfada00ff4fb195cb7224912f83f71c78c5523 100644 (file)
@@ -138,7 +138,11 @@ context("URL check functions", function()
     }},
     {"http://@@example.com", true, {
       user = "@", host = "example.com"
-    }}
+    }},
+    {"https://example.com\\_Resources\\ClientImages\\UserData?ol\\o#ololo\\", true, {
+      host = "example.com", path = "_Resources/ClientImages/UserData",
+      query = "ol\\o", fragment = "ololo\\",
+    }},
   }
 
   -- Some cases from https://code.google.com/p/google-url/source/browse/trunk/src/url_canon_unittest.cc