]> source.dussan.org Git - rspamd.git/commitdiff
[Fix] Fix emails detection
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Sat, 21 Oct 2017 11:07:58 +0000 (12:07 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Sat, 21 Oct 2017 11:07:58 +0000 (12:07 +0100)
MFH: rspamd-1.6

src/libserver/url.c

index 4d458e15a7e872fc1db75bf6685202aead15d965..ef04df04e01b63755c1226c943f288a80015cc1e 100644 (file)
@@ -2111,7 +2111,14 @@ url_email_end (struct url_callback_data *cb,
                }
 
                c = pos - 1;
-               while (c > cb->begin && is_mailsafe (*c)) {
+               while (c > cb->begin) {
+                       if (!is_mailsafe (*c)) {
+                               break;
+                       }
+                       if (c == match->prev_newline_pos) {
+                               break;
+                       }
+
                        c --;
                }
                /* Rewind to the first alphanumeric character */
@@ -2122,14 +2129,19 @@ url_email_end (struct url_callback_data *cb,
                /* Find the end of email */
                p = pos + 1;
                while (p < cb->end && is_domain (*p)) {
+                       if (p == match->newline_pos) {
+                               break;
+                       }
+
                        p ++;
                }
+
                /* Rewind it again to avoid bad emails to be detected */
                while (p > pos && p < cb->end && !g_ascii_isalnum (*p)) {
                        p --;
                }
 
-               if (p < cb->end && g_ascii_isalnum (*p)) {
+               if (p < cb->end && p < match->newline_pos && g_ascii_isalnum (*p)) {
                        p ++;
                }