]> source.dussan.org Git - rspamd.git/commitdiff
[Fix] Restore multiple values in headers processing
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Thu, 4 Aug 2016 15:00:14 +0000 (16:00 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Thu, 4 Aug 2016 15:00:14 +0000 (16:00 +0100)
src/libutil/http.c
src/libutil/http.h
src/libutil/http_private.h

index 931ed5ed84c7e995b2937e6cb3a4ae2baa9be3cb..7e5da1b12bb0f5057a243df7ce0744cada38ea68 100644 (file)
@@ -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)
index 9dc6302c9de16ee267f730cff4a5ce4c5aaae8a0..399141e6099bdcd59484fe139f27458ea218538d 100644 (file)
@@ -375,6 +375,16 @@ const rspamd_ftok_t * rspamd_http_message_find_header (
                struct rspamd_http_message *msg,
                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
index 49575c03c2cc6df5594e136905fcfb186b956c7f..1433e37e451b3aee13b2d303528fe020bcc94d4b 100644 (file)
@@ -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;
 };
 
 /**