]> source.dussan.org Git - rspamd.git/commitdiff
[Fix] Lowercase HTTP headers to make them searchable from Lua
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Sat, 12 Aug 2017 19:11:48 +0000 (20:11 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Sat, 12 Aug 2017 19:26:17 +0000 (20:26 +0100)
src/lua/lua_http.c

index 34a31bde88a101ecec96591b00258974df1288c6..ad2a7d981d1c8f5e393224673cee9c1af6b41b54 100644 (file)
@@ -68,6 +68,7 @@ struct lua_http_cbdata {
        rspamd_inet_addr_t *addr;
        gchar *mime_type;
        gchar *host;
+       const gchar *url;
        gsize max_size;
        gint flags;
        gint fd;
@@ -202,6 +203,10 @@ lua_http_finish_handler (struct rspamd_http_connection *conn,
        lua_newtable (cbd->L);
 
        HASH_ITER (hh, msg->headers, h, htmp) {
+               /*
+                * Lowercase header name, as Lua cannot search in caseless matter
+                */
+               rspamd_str_lc (h->combined->str, h->name->len);
                lua_pushlstring (cbd->L, h->name->begin, h->name->len);
                lua_pushlstring (cbd->L, h->value->begin, h->value->len);
                lua_settable (cbd->L, -3);
@@ -607,6 +612,7 @@ lua_http_request (lua_State *L)
        cbd->local_kp = local_kp;
        cbd->flags = flags;
        cbd->max_size = max_size;
+       cbd->url = url;
 
        if (msg->host) {
                cbd->host = rspamd_fstring_cstr (msg->host);