]> source.dussan.org Git - rspamd.git/commitdiff
[Fix] Sigh, another email to string fix
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Tue, 22 Oct 2019 14:52:27 +0000 (15:52 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Tue, 22 Oct 2019 14:52:27 +0000 (15:52 +0100)
src/lua/lua_url.c

index 57be4c009e0b30ed1c76867aa68df301acaf44a6..4b923d3efa73c3cfa44da11b2540b6907b1c2bd4 100644 (file)
@@ -302,21 +302,15 @@ lua_url_tostring (lua_State *L)
 
        if (url != NULL && url->url != NULL) {
                if (url->url->protocol == PROTOCOL_MAILTO) {
-                       if (url->url->userlen + 1 + url->url->hostlen == url->url->urllen) {
-                               lua_pushlstring (L, url->url->string, url->url->urllen);
-                       }
-                       else {
-                               /* TODO: not efficient */
-                               gchar *tmp = g_malloc (url->url->userlen + 1 +
-                                               url->url->hostlen);
-                               memcpy (tmp, url->url->user, url->url->userlen);
-                               tmp[url->url->userlen] = '@';
-                               memcpy (tmp + url->url->userlen + 1, url->url->host,
-                                               url->url->hostlen);
-
-                               lua_pushlstring (L, tmp, url->url->userlen + 1 + url->url->hostlen);
-                               g_free (tmp);
-                       }
+                       gchar *tmp = g_malloc (url->url->userlen + 1 +
+                                                                  url->url->hostlen);
+                       memcpy (tmp, url->url->user, url->url->userlen);
+                       tmp[url->url->userlen] = '@';
+                       memcpy (tmp + url->url->userlen + 1, url->url->host,
+                                       url->url->hostlen);
+
+                       lua_pushlstring (L, tmp, url->url->userlen + 1 + url->url->hostlen);
+                       g_free (tmp);
                }
                else {
                        lua_pushlstring (L, url->url->string, url->url->urllen);