diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2017-12-26 17:12:11 +0000 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2017-12-26 17:12:11 +0000 |
commit | d413a9fe656591bfb94def878c63e1768c30c522 (patch) | |
tree | 50503f6c4b6105c78a775bc2e3119b56312c2890 | |
parent | 041d3b0282e51227a627d02c6615ea13329afd3f (diff) | |
download | rspamd-d413a9fe656591bfb94def878c63e1768c30c522.tar.gz rspamd-d413a9fe656591bfb94def878c63e1768c30c522.zip |
[Fix] Replace space like characters in headers with plain space
-rw-r--r-- | rules/regexp/headers.lua | 4 | ||||
-rw-r--r-- | src/libmime/mime_headers.c | 10 | ||||
-rw-r--r-- | src/libserver/re_cache.c | 5 |
3 files changed, 13 insertions, 6 deletions
diff --git a/rules/regexp/headers.lua b/rules/regexp/headers.lua index b375f6598..8dc8e9777 100644 --- a/rules/regexp/headers.lua +++ b/rules/regexp/headers.lua @@ -862,14 +862,14 @@ reconf['SUBJECT_HAS_EXCLAIM'] = { } reconf['SUBJECT_ENDS_QUESTION'] = { - re = 'Subject=/\\?\\s*$/H', + re = 'Subject=/\\?\\s*$/Hu', description = 'Subject ends with a question', score = 1.0, group = 'headers' } reconf['SUBJECT_HAS_QUESTION'] = { - re = string.format('%s & !%s', 'Subject=/\\?/H', 'Subject=/\\?\\s*$/H'), + re = string.format('%s & !%s', 'Subject=/\\?/H', 'Subject=/\\?\\s*$/Hu'), description = 'Subject contains a question', score = 0.0, group = 'headers' diff --git a/src/libmime/mime_headers.c b/src/libmime/mime_headers.c index 0564379e4..81a7b666a 100644 --- a/src/libmime/mime_headers.c +++ b/src/libmime/mime_headers.c @@ -516,8 +516,14 @@ rspamd_mime_header_sanity_check (GString *str) for (i = 0; i < str->len; i ++) { t = str->str[i]; - if (!((t & 0x80) || g_ascii_isgraph (t) || t == ' ')) { - str->str[i] = '?'; + if (!((t & 0x80) || g_ascii_isgraph (t))) { + if (g_ascii_isspace (t)) { + /* Replace spaces characters with plain space */ + str->str[i] = ' '; + } + else { + str->str[i] = '?'; + } } } } diff --git a/src/libserver/re_cache.c b/src/libserver/re_cache.c index 9aad6b591..d0e17603d 100644 --- a/src/libserver/re_cache.c +++ b/src/libserver/re_cache.c @@ -809,9 +809,10 @@ rspamd_re_cache_exec_re (struct rspamd_task *task, ret = rspamd_re_cache_process_regexp_data (rt, re, task, scvec, lenvec, headerlist->len, raw); - msg_debug_re_task ("checking header %s regexp: %s -> %d", + msg_debug_re_task ("checking header %s regexp: %s=%*s -> %d", re_class->type_data, - rspamd_regexp_get_pattern (re), ret); + rspamd_regexp_get_pattern (re), + (int)lenvec[0], scvec[0], ret); g_free (scvec); g_free (lenvec); } |