]> source.dussan.org Git - rspamd.git/commitdiff
[Fix] Fix urls shifting when doing decode to include separators
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Wed, 15 Jan 2020 11:21:56 +0000 (11:21 +0000)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Wed, 15 Jan 2020 11:21:56 +0000 (11:21 +0000)
src/libserver/url.c
test/lua/unit/url.lua

index d792177e85de0507b55a4638781b4c36b598a67b..866cb4c22bbdfdd4b79d4ea23d51bab7c8e88ea6 100644 (file)
@@ -1810,7 +1810,7 @@ rspamd_url_shift (struct rspamd_url *uri, gsize nlen,
                old_shift = uri->hostlen;
                uri->hostlen -= shift;
                memmove (uri->host + uri->hostlen, uri->host + old_shift,
-                               uri->datalen + uri->querylen + uri->fragmentlen);
+                               uri->datalen + uri->querylen + uri->fragmentlen + 1);
                uri->urllen -= shift;
                uri->flags |= RSPAMD_URL_FLAG_HOSTENCODED;
                break;
@@ -1825,7 +1825,7 @@ rspamd_url_shift (struct rspamd_url *uri, gsize nlen,
                old_shift = uri->datalen;
                uri->datalen -= shift;
                memmove (uri->data + uri->datalen, uri->data + old_shift,
-                               uri->querylen + uri->fragmentlen);
+                               uri->querylen + uri->fragmentlen + 1);
                uri->urllen -= shift;
                uri->flags |= RSPAMD_URL_FLAG_PATHENCODED;
                break;
@@ -1840,7 +1840,7 @@ rspamd_url_shift (struct rspamd_url *uri, gsize nlen,
                old_shift = uri->querylen;
                uri->querylen -= shift;
                memmove (uri->query + uri->querylen, uri->query + old_shift,
-                               uri->fragmentlen);
+                               uri->fragmentlen + 1);
                uri->urllen -= shift;
                uri->flags |= RSPAMD_URL_FLAG_QUERYENCODED;
                break;
index e4baf5b6d77f9ded2e73c2d2ead426df5d47ee64..7f337c8b2f0865fcce58e708ddb3dc8195cd1c8b 100644 (file)
@@ -57,7 +57,7 @@ context("URL check functions", function()
 
   cases = {
     {'http://example.net/?arg=%23#fragment', true, {
-      host = 'example.net', fragment = 'fragment'
+      host = 'example.net', fragment = 'fragment', query = 'arg=#',
     }},
     {"http:/\\[::eeee:192.168.0.1]/#test", true, {
       host = '::eeee:c0a8:1', fragment = 'test'