]> source.dussan.org Git - rspamd.git/commitdiff
[Fix] Replace space like characters in headers with plain space
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Tue, 26 Dec 2017 17:12:11 +0000 (17:12 +0000)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Tue, 26 Dec 2017 17:12:11 +0000 (17:12 +0000)
rules/regexp/headers.lua
src/libmime/mime_headers.c
src/libserver/re_cache.c

index b375f6598d51d694388c9331c98f84a7882b371a..8dc8e9777dbe63cf880926078df19d85496a5029 100644 (file)
@@ -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'
index 0564379e47bf0687c001634473406d6d463e3156..81a7b666a8a4ddc7f76bcae99c13ec99b678b420 100644 (file)
@@ -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] = '?';
+                       }
                }
        }
 }
index 9aad6b5917adae571c6beb1c8093a0fbaaeba857..d0e17603d6b97e41ec897331f0654687604d4d1b 100644 (file)
@@ -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);
                }