const ucl_object_t *elt, *cur, *cur_elt;
ucl_object_iter_t it;
GString *hname, *hvalue;
+ gint idx = -1;
if (obj && ucl_object_type (obj) == UCL_OBJECT) {
elt = ucl_object_lookup (obj, "remove_headers");
/*
* add_headers: {"name": "value", ... }
* name could have multiple values
+ * -or- (since 1.7)
+ * {"name": {"value": "val", "order": 0}, ... }
*/
if (elt && ucl_object_type (elt) == UCL_OBJECT) {
it = NULL;
g_string_free (hname, TRUE);
g_string_free (hvalue, TRUE);
}
+ else if (ucl_object_type (cur_elt) == UCL_OBJECT) {
+ const ucl_object_t *val;
+
+ val = ucl_object_lookup (cur_elt, "value");
+
+ if (val && ucl_object_type (val) == UCL_STRING) {
+ const ucl_object_t *idx_obj;
+
+ idx_obj = ucl_object_lookup_any (cur_elt, "order",
+ "index", NULL);
+ if (idx_obj) {
+ idx = ucl_object_toint (idx_obj);
+ }
+
+ hname = g_string_new (ucl_object_key (cur));
+ hvalue = g_string_new (ucl_object_tostring (val));
+
+ if (idx >= 0) {
+ rspamd_milter_send_action (session,
+ RSPAMD_MILTER_INSHEADER,
+ idx,
+ hname, hvalue);
+ }
+ else {
+ rspamd_milter_send_action (session,
+ RSPAMD_MILTER_ADDHEADER,
+ hname, hvalue);
+ }
+
+ g_string_free (hname, TRUE);
+ g_string_free (hvalue, TRUE);
+ }
+ }
}
}
}
hname = g_string_new (RSPAMD_MILTER_DKIM_HEADER);
hvalue = g_string_new (ucl_object_tostring (elt));
- rspamd_milter_send_action (session, RSPAMD_MILTER_ADDHEADER,
- hname, hvalue);
+ rspamd_milter_send_action (session, RSPAMD_MILTER_INSHEADER,
+ 0, hname, hvalue);
g_string_free (hname, TRUE);
g_string_free (hvalue, TRUE);
}