folded_symbuf = rspamd_header_value_fold ("X-Spam-Symbols",
symbuf->str,
- 0, nl_type);
+ 0, nl_type, ",");
rspamd_printf_gstring (added_headers, "X-Spam-Symbols: %v%s",
- folded_symbuf, line_end);
+ folded_symbuf, line_end, ",");
g_string_free (folded_symbuf, TRUE);
g_string_free (symbuf, TRUE);
if (task->flags & RSPAMD_TASK_FLAG_MILTER) {
folded_header = rspamd_header_value_fold ("DKIM-Signature",
- dkim_sig->str, 80, RSPAMD_TASK_NEWLINES_LF);
+ dkim_sig->str, 80, RSPAMD_TASK_NEWLINES_LF, NULL);
}
else {
folded_header = rspamd_header_value_fold ("DKIM-Signature",
- dkim_sig->str, 80, task->nlines_type);
+ dkim_sig->str, 80, task->nlines_type, NULL);
}
/*
* According to milter docs, we need to be extra careful
rspamd_header_value_fold (const gchar *name,
const gchar *value,
guint fold_max,
- enum rspamd_newlines_type how)
+ enum rspamd_newlines_type how,
+ const gchar *fold_on_chars)
{
GString *res;
const guint default_fold_max = 76;
cur_len ++;
}
}
+ else if (fold_on_chars && strchr (fold_on_chars, *p) != NULL) {
+ fold_type = fold_after;
+ state = fold_token;
+ next_state = read_token;
+
+ p ++;
+ }
else {
p ++;
cur_len ++;
* Fold header using rfc822 rules, return new GString from the previous one
* @param name name of header (used just for folding)
* @param value value of header
+ * @param fold_max
+ * @param how
+ * @param fold_on_chars
* @return new GString with the folded value
*/
GString *rspamd_header_value_fold (const gchar *name,
const gchar *value,
guint fold_max,
- enum rspamd_newlines_type how);
+ enum rspamd_newlines_type how,
+ const gchar *fold_on_chars);
/**
* Search for a substring `srch` in the text `in` using Apostolico-Crochemore algorithm
LUA_FUNCTION_DEF (util, parse_addr);
/***
- * @function util.fold_header(name, value)
+ * @function util.fold_header(name, value, [how, [stop_chars]])
* Fold rfc822 header according to the folding rules
*
* @param {string} name name of the header
* @param {string} value value of the header
+ * @param {string} how "cr" for \r, "lf" for \n and "crlf" for \r\n (default)
+ * @param {string} stop_chars also fold header when the
* @return {string} Folded value of the header
*/
LUA_FUNCTION_DEF (util, fold_header);
static gint
lua_util_fold_header (lua_State *L)
{
- const gchar *name, *value, *how;
+ const gchar *name, *value, *how, *stop_chars = NULL;
GString *folded;
name = luaL_checkstring (L, 1);
if (name && value) {
if (lua_isstring (L, 3)) {
+
how = lua_tostring (L, 3);
+ if (lua_isstring (L, 4)) {
+ stop_chars = lua_tostring (L, 4);
+ }
+
if (strcmp (how, "cr") == 0) {
folded = rspamd_header_value_fold (name, value, 0,
- RSPAMD_TASK_NEWLINES_CR);
+ RSPAMD_TASK_NEWLINES_CR, stop_chars);
}
else if (strcmp (how, "lf") == 0) {
folded = rspamd_header_value_fold (name, value, 0,
- RSPAMD_TASK_NEWLINES_LF);
+ RSPAMD_TASK_NEWLINES_LF, stop_chars);
}
else {
folded = rspamd_header_value_fold (name, value, 0,
- RSPAMD_TASK_NEWLINES_CRLF);
+ RSPAMD_TASK_NEWLINES_CRLF, stop_chars);
}
}
else {
folded = rspamd_header_value_fold (name, value, 0,
- RSPAMD_TASK_NEWLINES_CRLF);
+ RSPAMD_TASK_NEWLINES_CRLF, stop_chars);
}
if (folded) {