diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2016-08-04 16:00:14 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2016-08-04 16:00:14 +0100 |
commit | de16089822abd364dbe73b1f7ebd45dd185934b4 (patch) | |
tree | 2eb63b8905943338669e31613019f74c47d9f229 /src/libutil | |
parent | feef96256730fd94afe3ea4e5d51db9763f2e535 (diff) | |
download | rspamd-de16089822abd364dbe73b1f7ebd45dd185934b4.tar.gz rspamd-de16089822abd364dbe73b1f7ebd45dd185934b4.zip |
[Fix] Restore multiple values in headers processing
Diffstat (limited to 'src/libutil')
-rw-r--r-- | src/libutil/http.c | 43 | ||||
-rw-r--r-- | src/libutil/http.h | 10 | ||||
-rw-r--r-- | src/libutil/http_private.h | 1 |
3 files changed, 52 insertions, 2 deletions
diff --git a/src/libutil/http.c b/src/libutil/http.c index 931ed5ed8..7e5da1b12 100644 --- a/src/libutil/http.c +++ b/src/libutil/http.c @@ -521,6 +521,8 @@ static void rspamd_http_finish_header (struct rspamd_http_connection *conn, struct rspamd_http_connection_private *priv) { + struct rspamd_http_header *hdr; + priv->header->combined = rspamd_fstring_append (priv->header->combined, "\r\n", 2); priv->header->value->len = priv->header->combined->len - @@ -528,8 +530,18 @@ rspamd_http_finish_header (struct rspamd_http_connection *conn, priv->header->value->begin = priv->header->combined->str + priv->header->name->len + 2; priv->header->name->begin = priv->header->combined->str; - HASH_ADD_KEYPTR (hh, priv->msg->headers, priv->header->name->begin, - priv->header->name->len, priv->header); + + HASH_FIND (hh, priv->msg->headers, priv->header->name->begin, + priv->header->name->len, hdr); + + if (hdr) { + DL_APPEND (priv->msg->headers, priv->header); + } + else { + HASH_ADD_KEYPTR (hh, priv->msg->headers, priv->header->name->begin, + priv->header->name->len, priv->header); + } + rspamd_http_check_special_header (conn, priv); } @@ -2632,6 +2644,33 @@ rspamd_http_message_find_header (struct rspamd_http_message *msg, return res; } +GPtrArray* +rspamd_http_message_find_header_multiple ( + struct rspamd_http_message *msg, + const gchar *name) +{ + GPtrArray *res = NULL; + struct rspamd_http_header *hdr, *cur; + + guint slen = strlen (name); + + if (msg != NULL) { + HASH_FIND (hh, msg->headers, name, slen, hdr); + + if (hdr) { + res = g_ptr_array_sized_new (4); + + LL_FOREACH (hdr, cur) { + g_ptr_array_add (res, cur->value); + } + } + } + + + return res; +} + + gboolean rspamd_http_message_remove_header (struct rspamd_http_message *msg, const gchar *name) diff --git a/src/libutil/http.h b/src/libutil/http.h index 9dc6302c9..399141e60 100644 --- a/src/libutil/http.h +++ b/src/libutil/http.h @@ -376,6 +376,16 @@ const rspamd_ftok_t * rspamd_http_message_find_header ( const gchar *name); /** + * Search for a header that has multiple values + * @param msg + * @param name + * @return list of rspamd_ftok_t * with values + */ +GPtrArray* rspamd_http_message_find_header_multiple ( + struct rspamd_http_message *msg, + const gchar *name); + +/** * Remove specific header from a message * @param msg * @param name diff --git a/src/libutil/http_private.h b/src/libutil/http_private.h index 49575c03c..1433e37e4 100644 --- a/src/libutil/http_private.h +++ b/src/libutil/http_private.h @@ -30,6 +30,7 @@ struct rspamd_http_header { rspamd_ftok_t *value; rspamd_fstring_t *combined; UT_hash_handle hh; + struct rspamd_http_header *prev, *next; }; /** |