From f8d42f581eb0c1eb4fe90a46317fa97024199102 Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Sat, 12 Aug 2017 20:11:48 +0100 Subject: [PATCH] [Fix] Lowercase HTTP headers to make them searchable from Lua --- src/lua/lua_http.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/lua/lua_http.c b/src/lua/lua_http.c index a655b8ec0..99a967db7 100644 --- a/src/lua/lua_http.c +++ b/src/lua/lua_http.c @@ -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); @@ -604,6 +609,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); -- 2.39.5