From 092fa9c14831bc0460bd25190fa013697f572354 Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Wed, 15 Jan 2020 11:21:56 +0000 Subject: [PATCH] [Fix] Fix urls shifting when doing decode to include separators --- src/libserver/url.c | 6 +++--- test/lua/unit/url.lua | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/libserver/url.c b/src/libserver/url.c index d792177e8..866cb4c22 100644 --- a/src/libserver/url.c +++ b/src/libserver/url.c @@ -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; diff --git a/test/lua/unit/url.lua b/test/lua/unit/url.lua index e4baf5b6d..7f337c8b2 100644 --- a/test/lua/unit/url.lua +++ b/test/lua/unit/url.lua @@ -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' -- 2.39.5